TermFilter and Array-Fields - bug or intended behaviour

Hello,

I if one has an ArrayField like

field = ["Val1","Val2","Val3"]

and its not_analyzed by mapping then in case a Filter is tried to be
put over it:

FilterBuilders.termFilter("field", "Val1");

the resulting query the flter is put to will allways have 0 results.

Is this intended or a bug?

Best

This filter will work. Have you called refresh before you executed the search and after you indexed the document? If it still does not work, gist a curl recreation (Elasticsearch Platform — Find real-time answers at scale | Elastic).
On Thursday, March 10, 2011 at 3:33 PM, K.B. wrote:

Hello,

I if one has an ArrayField like

field = ["Val1","Val2","Val3"]

and its not_analyzed by mapping then in case a Filter is tried to be
put over it:

FilterBuilders.termFilter("field", "Val1");

the resulting query the flter is put to will allways have 0 results.

Is this intended or a bug?

Best

Hi KB

I if one has an ArrayField like

field = ["Val1","Val2","Val3"]

and its not_analyzed by mapping then in case a Filter is tried to be
put over it:

FilterBuilders.termFilter("field", "Val1");

the resulting query the flter is put to will allways have 0 results.

I'm not seeing this. My example shows the correct behaviour:

Are you sure that your field is mapped as not_analyzed?

Try retrieving the mapping from Elasticsearch and see what it thinks the
mapping is.

Clint

Hello,

mapping seems correct, ES tells me:

...
linie_mv: {
* index: not_analyzed
* type: string
}
...

as expected (field is called differently here); As all other requests
to these fields work, I expect it to be indexed :slight_smile:

see gist:

If you do a queryString query and add a filter to the builder it will
give you empty returns;

On 10 Mrz., 14:51, Clinton Gormley clin...@iannounce.co.uk wrote:

Hi KB

I if one has an ArrayField like

field = ["Val1","Val2","Val3"]

and its not_analyzed by mapping then in case a Filter is tried to be
put over it:

FilterBuilders.termFilter("field", "Val1");

the resulting query the flter is put to will allways have 0 results.

I'm not seeing this. My example shows the correct behaviour:

ElasticSearch - not_analyzed array · GitHub

Are you sure that your field is mapped as not_analyzed?

Try retrieving the mapping from Elasticsearch and see what it thinks the
mapping is.

Elasticsearch Platform — Find real-time answers at scale | Elastic...

Clint

Hiya

as expected (field is called differently here); As all other requests
to these fields work, I expect it to be indexed :slight_smile:

see gist:

Query is ok but will return null! · GitHub

If you do a queryString query and add a filter to the builder it will
give you empty returns;

I've updated my example to show your same query with a query string, and
that it does work:

I think your data is not what you think it is.

If you try to recreate this problem from scratch, I think you will find
where your issue is (or failing that, that it now works :slight_smile:

hth

clint

heya clint,

thanks for answer but you're cheating :wink:

You do:

{
"query" : {
"filtered" : {
"query" : {
"query_string" : {
"query" : "*"
}
},
"filter" : {
"term" : {
"field" : "Val1"
}
}
}
}
}

While my java ends up in:

{
"filtered":{
"query":{
"query_string":{
"query":"*"
}
},
"filter":{
"term":{
"field":"Val1"
}
}
}
}

see, you put a big query around your 2 queries, while the java
transformates to the thing shown below - and that gives null back in
elasticsearch-head and gives no error as valid JSON;

My data seems ok as it works with either your JSON code or if I put it
into the first querystring;

Best

On 10 Mrz., 15:59, Clinton Gormley clin...@iannounce.co.uk wrote:

Hiya

as expected (field is called differently here); As all other requests
to these fields work, I expect it to be indexed :slight_smile:

see gist:

Query is ok but will return null! · GitHub

If you do a queryString query and add a filter to the builder it will
give you empty returns;

I've updated my example to show your same query with a query string, and
that it does work:

ElasticSearch - not_analyzed array · GitHub

I think your data is not what you think it is.

If you try to recreate this problem from scratch, I think you will find
where your issue is (or failing that, that it now works :slight_smile:

hth

clint

Hi KB

thanks for answer but you're cheating :wink:

see, you put a big query around your 2 queries, while the java
transformates to the thing shown below - and that gives null back in
elasticsearch-head and gives no error as valid JSON;

I'm not cheating :slight_smile: That is the correct syntax when using the HTTP API:

Whatever query you pass in needs to be passed as the value of the
'query' parameter. You can't pass a 'filtered' query as a top level
param.

Note: there was an incorrect example of a filtered query on

which I have now fixed.

clint

Ah, ok,

now thats different then.... ok, the JSON now seems ok and - please
dont ask me why - my java also now works.... haven't changed a line,
just an appserver restart...

Thank you very much for your help,

Best

On 10 Mrz., 16:23, Clinton Gormley clin...@iannounce.co.uk wrote:

Hi KB

thanks for answer but you're cheating :wink:

see, you put a big query around your 2 queries, while the java
transformates to the thing shown below - and that gives null back in
elasticsearch-head and gives no error as valid JSON;

I'm not cheating :slight_smile: That is the correct syntax when using the HTTP API:

Elasticsearch Platform — Find real-time answers at scale | Elastic

Whatever query you pass in needs to be passed as the value of the
'query' parameter. You can't pass a 'filtered' query as a top level
param.

Note: there was an incorrect example of a filtered query onhttp://www.elasticsearch.org/guide/reference/api/search/
which I have now fixed.

clint