0

Suppose we have two entries for index "Phones" 1]iphone 6 2]iphone 7

1]if I search for "iphone 6" Exact match will have one record 2]if I search for "iphone" Partial match will have both record

So I want to toggle between above methods based on some condition. How can we do this in Elasticsearch ?

MMT
  • 81
  • 1
  • 3
  • Could you give an example of such `some condition`? – Pavel Vasilev Mar 01 '17 at 09:38
  • @PaulVasilev actually, I want to keep ways open for both partial and exact match. elasticsearch is providing "keyword" mapping for exact match but it will close the way of partial phrase search. I want to define in query where I can define it should be exact match or partial match. i.e. in above example, if I search "iphone" with exact match it should not return result with iphone 6 and iphone 7 and both should return if I define normal(partial) search in query. – MMT Mar 01 '17 at 10:43
  • what exactly do you mean by toggle, you want to support both the searches and return only one of them based on priority? If this is the case you can take a look at search relevancy, to boost the exact matched one. Otherwise a you will need a hack solution to toggle filters. – user3775217 Mar 01 '17 at 11:48
  • Now here again the usability/usecase define how you can modify/use relevancy. For instance if you are building autocomplete then the ordering based on relevancy is fine or if you are showing the results on a page then you can set size=1. – user3775217 Mar 01 '17 at 11:55
  • So you want to issue `exact` query if `$query.tokens.size() <= 1` and `partial` otherwise. Is that what you actually looking for? Can't it be driven by client-side? – Pavel Vasilev Mar 01 '17 at 21:42

0 Answers0