1
votes

I'm integrating elasticsearch into an asset tracking application. When I setup the mapping initially, I envisioned the 'brand' field being a single-term field like 'Hitachi', or 'Ford'. Instead, I'm finding that the brand field in the actual data contains multiple terms like: "MB 7 A/B", "B-7" or even "Brush Bull BB72X".

I have an autocomplete component setup now that I configured to do autocomplete against an edgeNGram field, and perform the actual search against an nGram field. It's completely useless the way I set it up because users expect the search results to be restricted to what the autocomplete matches.

Any suggestions on the best way to setup my mapping to support autocomplete and subsequent searches against a multiple term field like this? I'm considering a terms query against a keyword field, or possibly a match query with 'and' as the operator? I also have to deal with hyphens like "B-7".

1
Do you want "Bul" to autocomplete to "Brush Bull BB72X" too?javanna
No...For now I think prefix matching is a good place to start. I'm now building my autocomplete values by querying an edgeNGram field and then performing a phrase_prefix query against the same field when the user searches. Seems to be working but I'm still working on it. Any suggestions?Troy

1 Answers