Check if an array contains some value


#1

Hello,

Let's say I have created a field like this:

"market": [
            {
              "name":  ["name1","name2","name3","name4","name5" ]
            },
              {"place":["P1","P2","P3"]}
          ]

Now, I want to check if the field "name" contains the value "name3".

I've tried this filter, but it doesn't work.

filter {
elasticsearch {
				hosts => "localhost:9200"
				index=>"admin"
				query => 'market.name:(name3)'
				sort => "_id:asc"				 		
				fields => {host_machine =>  'host_machine' }
			}
}

But it doesn't do anything (no crash, no error message, just doesn't do anything).

What am I doing wrong?


#2

I could create a query_string:

GET admin/markets/_search
{
"query": {
    "nested" : {
        "path" : "market",
        "query" : {
            "bool" : {
                "filter" : 
                   {"query_string" : {
                       "query" : "market.name:(name3)"
                   
                }
           }               
         }
    }
}
}
}

It works fine, but I want to formulate it in elasticsearch plugin.


(system) #3

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