2

Is there any possibility to make a search on two non-complete words in the same field using Elasticsearch in Rails? I mean the situation when I could successfully search for example "victorian buildings" phrase by inserting into search input for example "vict bui" phrase (only beginnings of words, also with fuzziness).

Partial match (word_start, text_start etc. available in Searchkick) doesn't work in this project. I've also tried using wildcard queries, but it also failed. Maybe writing some custom mappings/settings would be a good idea?

Can I ask you for any suggestions on what to search/read to do this task?

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Marta
  • 51
  • 4
  • This answer should help: https://stackoverflow.com/questions/37168764/tokenizer-vs-token-filters/37169584#37169584 (hint: use a standard tokenizer with an edge-ngram token filter to tokenize prefixes of all tokens) – Val Jun 08 '18 at 07:31
  • it helped me :) thank you – Marta Jun 12 '18 at 15:29
  • Can you update your question to explain why partial match doesn't work? `word_start` is designed for this use case. – Andrew Kane Aug 09 '18 at 07:53
  • this https://opster.com/elasticsearch-glossary/elasticsearch-autocomplete-troubleshooting-guide/ should help – Amit Mar 25 '20 at 19:49

1 Answers1

-1
Try this example


"%#{params[:place]}%"


Since % is a wildcard, doing a like on '%%' matches everything, 

and you get all the records in the result.

Raj
  • 66
  • 9