Match query does not give expected result

Hi,

I am not sure if I am doing something wrong, but I cant see expected results for match query.
I have followed ES documents and tried making a curl request with below json body

{
    "query": {
        "match" : {
            "title" : {
                "query" : "this test",
                "operator" : "or"
            }
        }
    }
} 

Complete title value is: "this is a test". Though when I make a call using below equivalent bool query, I am getting results:

  {
"query" :{
  "bool": {
"should": [
  { "term": { "title": "this" }},
  { "term": { "title": "test"   }}
]
  }
  }
  }

can you provide a fully reproducible example including index/mapping creation and indexing of documents? This way it is easier to follow your problem.

Hi Reelsen,

Thanks for quick response. Below are curl call results:

curl http://localhost:9201/esIndex

{"esIndex":{"aliases":{},"mappings":{"esType":{"properties":{"@timestamp":{"type":"date"},"@version":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"alias":{"type":"text","analyzer":"str_index_analyzer","search_analyzer":"str_search_analyzer"},"boost_value":{"type":"long"},"category":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"pub_date":{"type":"long"},"search_suggetion":{"type":"boolean"},"tag":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"title":{"type":"text","analyzer":"str_index_analyzer","search_analyzer":"str_search_analyzer"},"type":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}},"settings":{"index":{"number_of_shards":"5","provided_name":"esIndex","creation_date":"1530625714142","analysis":{"filter":{"substring":{"type":"nGram","min_gram":"1","max_gram":"20"}},"analyzer":{"str_index_analyzer":{"filter":["lowercase","substring"],"tokenizer":"keyword"},"str_search_analyzer":{"filter":["lowercase"],"tokenizer":"keyword"}}},"number_of_replicas":"1","uuid":"<uuid>","version":{"created":"6020399"}}}}}

Inserting records :

curl -X PUT "localhost:9201/esindex/estype/<id>" -H 'Content-Type: application/json' -d'
{
 "pub_date": 1520346474000,
    "@timestamp": "2018-03-06T14:27:54.666Z",
    "boost_value": 1,
    "search_suggetion": false,
    "@version": "1",
    "alias": "this is a test",
    "id": "<id>",
    "tag": "test",
    "type": "estype",
    "title": "this is a test",
}' 

/_cat/indices gievs below output:

green open esindex uuid 5 1 14 0 976.9kb 488.4kb

See this example

POST esindex/_analyze
{
  "analyzer" : "str_index_analyzer",
  "text" : "this is a test"
}

POST esindex/_analyze
{
  "analyzer" : "str_search_analyzer",
  "text" : "this test"
}

the output of the second analyze call just returns this test and this token is not emitted by the first call and thus never stored in the inverted index.

1 Like

Thanks a lot Reelsen.

Fixed it, and got better picture of ES.

1 Like

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