Match all fields except one

(Peter Dunham) #1


I have a collection of products, all with different attributes. I want to do a search on all attributes EXCEPT name, what is the easiest way to do this?

Thanks in advance.

(Joshua Rich) #2

In your field mapping, you can specify "index": "no" for the name field which will result in that field not being searchable at all, for all searches. If you just need to disable searching on that field for this particular search, you've really got no option but to use a multi_match query and explicitly list all the fields except the name field.

(Peter Dunham) #3

Thanks for your response.

How about if I have 2 indexes, one with all fields, one with all except name. Then I can specify a different index at search time, could that work?

(Camilo Sierra) #4

they are multiple possibilities, as you say you can duplicate your data or for use less disk space and memory you can create one index with all except name, and for the second one you can index only the name,
For the query use *multiple indices if you search in both indexes data + name or search only in the first index (all data except the name) if you need search only n your data...
or even better as say @Joshua_Rich use the multi_match query !

(Peter Dunham) #5

I will try the 2 index approach first, thanks for your help

(system) #6