Simple Search Problem on ElasticSearch

I am using elasticsearch 2.1. I do not quite understand what I am doing wrong. This makes it difficult for me to distinguish between queries, filters ... Could you help me?

I am trying to fulfill this request. It returns me an empty result:

curl -XGET 'http://ESNode01:9201/living_team/inputs/_search?pretty' -d '
{
    "query": {
        "filtered": { 
            "query": { "match_all": {} },
            "filter": { "term": { "channel": "Feina" } }
        }
     }
}
'

However, when I execute this request without filters, it returns me everything:

curl -XGET 'http://ESNode01:9201/living_team/inputs/_search?pretty' -d '
{
    "query": {
        "filtered": { 
            "query": { "match_all": {} },
        }
     }
}
'

This is a sample document:

{
  "user":"living_team",
  "timestamp":"2015-12-14T18:06:47.085Z",
  "matter":"snip2.PNG",
  "comment":"Archive",
  "channel":"Feina",
  "feedTypes":[
     20
  ],
  "property_general_ldate":"2015-12-14T18:06:47.085Z",
  "property_tSize":7595.0,
  "resources":[
     {
        "timestamp":"2015-12-14T16:58:00.598Z",
        "matter":"snip2.PNG",
        "comment":"Archive",
        "channel":"Feina",
        "feedType":20,
        "mime":"image/png",
        "source":{
           "sourceId":{
              "id":"C:\\Users\\Beep\\Desktop\\share\\snip2.PNG",
              "batch":"c38eec2d-a282-11e5-baf4-382c4ab9e433",
              "client":"VIM12HCNZL"
           },
           "feedType":20,
           "property_folder":"C:\\Users\\Beep\\Desktop\\share",
           "property_lastAccessFolder_ldate":1450111821506
        },
        "property_size":7595.0,
        "property_creation_ldate":"2015-12-14T16:50:20.578Z",
        "property_name":"snip2.PNG",
        "nestedResources":[

        ]
     }
  ]
+1
source share
2 answers

That should work.

curl - XGET 'http://ESNode01:9201/living_team/inputs/_search?pretty' - d ' {
{
    "query": {"match": {
       "channel": "feina"    }}
}'
+1
source

The field channelis likely, analyzedand therefore, it is indexed as a row with a bottom row. Instead, the following query will work (i.e., C feinain lower case):

curl -XGET 'http://ESNode01:9201/living_team/inputs/_search?pretty' -d '
{
    "query": {
        "filtered": { 
            "query": { "match_all": {} },
            "filter": { "term": { "channel": "feina" } }
        }
     }
}
'

, channel not_analyzed , term feina ( feina ). , , .

+2

Source: https://habr.com/ru/post/1620084/


All Articles