Bool must behaviour


(GX) #1

Hi all when running the query containing:

            "bool": {
                "must":
                    {
                        "term": {
                            "operators": [
                                "35",
                                "12",
                                "51",
                                "55",
                                "14",
                                "29"
                            ]
                        }
                    }

sometimes the result is empty and sometimes it has values and I cant
make out why, full example at

The actual data has many "operators" this is just a simplified version
I cant figure why

"operators": [ "35", "12", "51", "55", "14", "19" ] fails
"operators": [ "35", "12", "51", "55", "14", "29" ] works

once a match is found does every following value have to be a match?
I am truing to replicate an SQL condition "where operators in ('35',
'12', "51', '55', '14', '29')"

Running elasticsearch 0.18.7 java version 7


(medcl.net) #2

you should use terms-query or terms-filter instead of term query,
http://www.elasticsearch.org/guide/reference/query-dsl/terms-filter.html

"bool": {
"must":
{
"terms": {
"operators": [
"35",
"12",
"51",
"55",
"14",
"29"
]
}
}

-----Original Message-----
From: GX
Sent: Sunday, May 06, 2012 11:41 PM
To: elasticsearch
Subject: bool must behaviour

Hi all when running the query containing:

            "bool": {
                "must":
                    {
                        "term": {
                            "operators": [
                                "35",
                                "12",
                                "51",
                                "55",
                                "14",
                                "29"
                            ]
                        }
                    }

sometimes the result is empty and sometimes it has values and I cant
make out why, full example at

The actual data has many "operators" this is just a simplified version
I cant figure why

"operators": [ "35", "12", "51", "55", "14", "19" ] fails
"operators": [ "35", "12", "51", "55", "14", "29" ] works

once a match is found does every following value have to be a match?
I am truing to replicate an SQL condition "where operators in ('35',
'12', "51', '55', '14', '29')"

Running elasticsearch 0.18.7 java version 7


(GX) #3

Thanks for the reply.

A stupid oversight in my part, it works now.

GX

On May 7, 5:29 am, medcl2...@gmail.com wrote:

you should use terms-query or terms-filter instead of term query,http://www.elasticsearch.org/guide/reference/query-dsl/terms-filter.html

"bool": {
"must":
{
"terms": {
"operators": [
"35",
"12",
"51",
"55",
"14",
"29"
]
}
}

-----Original Message-----
From: GX
Sent: Sunday, May 06, 2012 11:41 PM
To: elasticsearch
Subject: bool must behaviour

Hi all when running the query containing:

            "bool": {
                "must":
                    {
                        "term": {
                            "operators": [
                                "35",
                                "12",
                                "51",
                                "55",
                                "14",
                                "29"
                            ]
                        }
                    }

sometimes the result is empty and sometimes it has values and I cant
make out why, full example athttps://gist.github.com/e0512a077960469fca54

The actual data has many "operators" this is just a simplified version
I cant figure why

"operators": [ "35", "12", "51", "55", "14", "19" ] fails
"operators": [ "35", "12", "51", "55", "14", "29" ] works

once a match is found does every following value have to be a match?
I am truing to replicate an SQL condition "where operators in ('35',
'12', "51', '55', '14', '29')"

Running elasticsearch 0.18.7 java version 7


(system) #4