How not to query on specific fields in elasticsearch

My usecase demands to search on all fields for a given keyword except 2 fields. must_not is not working, Pls guide.

Thanks

to set up parmeter 'include_in_all ' in mappings on the 2 fields, and use query_string or simple_query_string query.
https://www.elastic.co/guide/en/elasticsearch/reference/5.2/include-in-all.html
https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-simple-query-string-query.html

Thanks Wenpos for the reply. But I will need these 2 fields in other queries, so I cannot do an "include_in_all" to false, since it may bother my other queries. Pls let me know if there is a way out.

Thanks

The two fields can also be assigned in query DSL, no matter set it “include_in_all” or not. If you need not use _all, you 'd better have specific fields.
--Fanfan

Why the must_not is not working ?

If you have a bool query with one must on all fields and one must_not on both fields, it should be ok ?

I am not sure... may be loosing something while mapping

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.