Hello,
I want to use "all_field" option in my queries to search all indexed fields, but excluding a few. I have elastic search 5.2.1 installed and sent below commands using Kibana to elastic search.
PUT test_index
{
"mappings": {
"user": {
"_all": { "enabled": false },
"properties": {
"title": { "type": "text" },
"name": { "type": "text" },
"age": { "type": "integer" }
}
}
}
}
POST test_index/_bulk
{ "index" : { "_type" : "user", "_id" : "1" } }
{ "name" : "niaz", "title" : "test", "age" : 40, "tags" : "toyota, bmw" }
{ "index" : { "_type" : "user", "_id" : "2" } }
{ "name" : "john", "title" : "toyota", "age" : 30 }
{ "index" : { "_type" : "user", "_id" : "3" } }
{ "name" : "bell", "title" : "mercedes", "age" : 35 }
{ "index" : { "_type" : "user", "_id" : "4" } }
{ "name" : "akram", "title" : "bmw", "age" : 42 }
GET test_index/_search
{
"query": {
"query_string": {
"query": "toyota"
}
}
}
The query returns me 2 documents, this is 100% correct. The question is how can I change my all_field configuration that the query should exclude the "tags" field from search.
In general, I can configure the custom _all field OR send the query with multiple-fields. But then my fields will be either indexed twice OR for each query I need to send a large list of fields to elastic search.
Thanks a lot in advance for your help.
Greetings,
Niaz