0

If I were to create a query like this:

"query": {
  "query_string": {
    "query": "User:mjohnst",
    "default_field": "Text",
    "fields": [
       "Text",
       "ProcessedText"
    ], 
    "default_operator": "and",
    "lowercase_expanded_terms": false
  }
}

Where the query_string -> query is specifying a field explicitly, but the fields property is set to other fields, what is the expected behavior? Will User, Text, and ProcessedText be searched, or just User?

2 Answers 2

1

The simplest way to test it is by using validate query API:

curl "localhost:9200/test/doc/_validate/query?pretty&explain" -d '{
    "query": {
        "query_string": {
            "query": "User:mjohnst blah",
            "default_field": "Text",
            "fields": [
                "Text",
                "ProcessedText"
            ],
            "default_operator": "and",
            "lowercase_expanded_terms": false
        }
    }
}'

{
  "valid" : true,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "explanations" : [ {
    "index" : "test",
    "valid" : true,
    "explanation" : "filtered(+User:mjohnst +(Text:blah | ProcessedText:blah))->cache(_type:doc)"
  } ]
}

As you can see the term with explicitly specified field mjonst is searched against this field (User) the term blahwithout field is searched against all fields in the fields list.

Sign up to request clarification or add additional context in comments.

Comments

0

Tested this out on some documents and it will only return the documents that match the search on just User

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.