QueryString query on not_analyzed field


(Aarón Martín Bermejo) #1

Hello,

My problem is that I have a not_analyzed field and I'm doing a query_string
query over it searching the first word of the field. That query doesn't
return anything. It can be reproduced doing the next steps:

  1. Create an index with the next mapping: http://pastebin.com/Bz4qxEDS

  2. Index an object at the index "test1" with the next json:
    {"TextProperty": "This-is-a-test-property"}

  3. Make the next query: {"query": {"bool": {"must": [{"query_string":
    {"default_field": "TextProperty","query": "This"}}]}}}

The query does not return anything. But if I change the query for "his"
it doues return the object previously indexed.

I'm doing this query because I want to make a query that returns every
result that "contains" the value I'm searching. I don't know if it's normal
that over not_indexed fields the query string queries don't work as
expected or maybe I should make another kind of query or anything else. The
point is that that query does not work.

I'm open to any solution.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/62651c7b-9f07-4f1e-b0e6-4326d83b3d7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Aarón Martín Bermejo) #2

Someone can help me please?

El miércoles, 25 de junio de 2014 10:11:43 UTC+2, Aarón Martín Bermejo
escribió:

Hello,

My problem is that I have a not_analyzed field and I'm doing a
query_string query over it searching the first word of the field. That
query doesn't return anything. It can be reproduced doing the next steps:

  1. Create an index with the next mapping: http://pastebin.com/Bz4qxEDS

  2. Index an object at the index "test1" with the next json:
    {"TextProperty": "This-is-a-test-property"}

  3. Make the next query: {"query": {"bool": {"must": [{"query_string":
    {"default_field": "TextProperty","query": "This"}}]}}}

The query does not return anything. But if I change the query for "his"
it doues return the object previously indexed.

I'm doing this query because I want to make a query that returns every
result that "contains" the value I'm searching. I don't know if it's normal
that over not_indexed fields the query string queries don't work as
expected or maybe I should make another kind of query or anything else. The
point is that that query does not work.

I'm open to any solution.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/fce70d28-69e4-47a4-9a44-97dc9202097d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(David Pilato) #3

This one is working:

GET test/test1/_search
{
"query": {
"wildcard": {
"TextProperty": "This"
}
}
}

But note that you should not do that.

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html

Note this query can be slow, as it needs to iterate over many terms. In order to prevent extremely slow wildcard queries, a wildcard term should not start with one of the wildcards * or ?.

You'd better use a ngram token filter.

My 2 cents

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr

Le 4 juillet 2014 à 10:22:53, Aarón Martín Bermejo (aamarber@karira.es) a écrit:

Someone can help me please?

El miércoles, 25 de junio de 2014 10:11:43 UTC+2, Aarón Martín Bermejo escribió:
Hello,

My problem is that I have a not_analyzed field and I'm doing a query_string query over it searching the first word of the field. That query doesn't return anything. It can be reproduced doing the next steps:

  1. Create an index with the next mapping: http://pastebin.com/Bz4qxEDS

  2. Index an object at the index "test1" with the next json: {"TextProperty": "This-is-a-test-property"}

  3. Make the next query: {"query": {"bool": {"must": [{"query_string": {"default_field": "TextProperty","query": "This"}}]}}}

The query does not return anything. But if I change the query for "his" it doues return the object previously indexed.

I'm doing this query because I want to make a query that returns every result that "contains" the value I'm searching. I don't know if it's normal that over not_indexed fields the query string queries don't work as expected or maybe I should make another kind of query or anything else. The point is that that query does not work.

I'm open to any solution.

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/fce70d28-69e4-47a4-9a44-97dc9202097d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.53b66b79.41b71efb.2fae%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/d/optout.


(Aarón Martín Bermejo) #4

Thanks a lot David! That one works and I will investigate on the ngram
token filter. Best regards!

El viernes, 4 de julio de 2014 10:53:25 UTC+2, David Pilato escribió:

This one is working:

GET test/test1/_search
{
"query": {
"wildcard": {
"TextProperty": "This"
}
}
}

But note that you should not do that.

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html

Note this query can be slow, as it needs to iterate over many terms. In
order to prevent extremely slow wildcard queries, a wildcard term should
not start with one of the wildcards * or ?.

You'd better use a ngram token filter.

My 2 cents

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfr
https://twitter.com/elasticsearchfr

Le 4 juillet 2014 à 10:22:53, Aarón Martín Bermejo (aama...@karira.es
<javascript:>) a écrit:

Someone can help me please?

El miércoles, 25 de junio de 2014 10:11:43 UTC+2, Aarón Martín Bermejo
escribió:

Hello,

My problem is that I have a not_analyzed field and I'm doing a
query_string query over it searching the first word of the field. That
query doesn't return anything. It can be reproduced doing the next steps:

  1. Create an index with the next mapping: http://pastebin.com/Bz4qxEDS

  2. Index an object at the index "test1" with the next json:
    {"TextProperty": "This-is-a-test-property"}

  3. Make the next query: {"query": {"bool": {"must": [{"query_string":
    {"default_field": "TextProperty","query": "This"}}]}}}

The query does not return anything. But if I change the query for "his"
it doues return the object previously indexed.

I'm doing this query because I want to make a query that returns every
result that "contains" the value I'm searching. I don't know if it's normal
that over not_indexed fields the query string queries don't work as
expected or maybe I should make another kind of query or anything else. The
point is that that query does not work.

I'm open to any solution.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/fce70d28-69e4-47a4-9a44-97dc9202097d%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/fce70d28-69e4-47a4-9a44-97dc9202097d%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/27b09516-9825-4a30-948d-93b61c01a91e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #5