typesense icon indicating copy to clipboard operation
typesense copied to clipboard

Question: Is there a way to narrow down the search results if I know the initial few exact words?

Open sameerkumar18 opened this issue 5 years ago • 8 comments

Description

Hi, I'm currently evaluating Typesense cloud for my product. I was wondering if there's a way through which I can mention initial exact words to narrow down the results and then search inside that resultset while searching on TypeSense cloud search? (string field) I'm not very sure if there's a filter that can do this..? For example, There are 7 docs in a collection

  1. Essel Large & Midcap Fund- Regular Plan- Normal Dividend Option
  2. Essel Large & Midcap Fund-Direct Plan-Annual Dividend
  3. Essel Large & Midcap Fund-Direct Plan-Half Yearly Dividend
  4. Essel Large & Midcap Fund-Regular Plan-Annual Dividend
  5. Franklin India Equity Advantage Fund - Direct - Dividend
  6. Franklin India Equity Advantage Fund - Direct - Growth
  7. Franklin India Equity Advantage Fund - Growth Plan

Here, while searching I am aware of the first few words "Essel Large & Midcap". Can I use these words to narrow down the result (via some sort of a filter), and then from those narrowed records, search any string like "Half" - The result here should be doc on the 3rd position i.e "3. Essel Large & Midcap Fund-Direct Plan-Half Yearly Dividend"

Also, are numbers omitted while searching in a string field?

Thank you!

sameerkumar18 avatar Dec 24 '20 12:12 sameerkumar18

👋 @sameerkumar18

Can I use these words to narrow down the result (via some sort of a filter)

Yes, you can achieve that by making the the field (let's call it title) a facet field in the collection and then when you query the collection, filter for it like this:

?q=half&query_by=title&filter_by=title:Essel Large & Midcap

Note that Typesense removes all non-alpha-numeric ASCII chars during indexing, so Midcap Fund-Regular Plan-Annual will be indexed as Midcap FundRegular PlanAnnual . To avoid this, replace hyphens with space before indexing and likewise during querying.

Also, are numbers omitted while searching in a string field?

No they are not omitted. Happy to answer any other questions.

kishorenc avatar Dec 24 '20 13:12 kishorenc

Thanks for the quick reply @kishorenc You're the MVP!

sameerkumar18 avatar Dec 26 '20 09:12 sameerkumar18

I was wondering if there's any way to narrow down the results by excluding some keywords in the field I'm searching for? For example in the above results, is there a way I can exclude keywords like filter_by=exclude: Advantage

sameerkumar18 avatar Dec 26 '20 09:12 sameerkumar18

Seems like a duplicate of #155 Thanks again!

sameerkumar18 avatar Dec 26 '20 09:12 sameerkumar18

Oops, seems like I misread something Issue 155 was for excluding facets AFAIK How do I exclude keywords while searching in normal non-facet fields?

cc @kishorenc

sameerkumar18 avatar Dec 26 '20 10:12 sameerkumar18

Issue #155 initially started off as a way to add exclusion as a facet filter, but eventually consensus was reached on doing it for the query. So this feature is available on the nightly build. You just need to prefix tokens that you want to exclude with a -.

How do you currently run Typesense: via docker or linux binary? I can link to a RC build here.

kishorenc avatar Dec 26 '20 15:12 kishorenc

@kishorenc I'm currently using Typsense Cloud. Not sure if there's an option to plug a custom build there?

sameerkumar18 avatar Dec 26 '20 18:12 sameerkumar18

@sameerkumar18 Custom builds are not exposed in the UI in Typesense Cloud. But I can upgrade your cluster from our end to the RC build if you’d like. Could you email contact at typesense dot org with your cluster id and I can take care of it.

jasonbosco avatar Dec 26 '20 18:12 jasonbosco