Query a document by field which is an array of strings?

Hi

My field relevancy_tags is index as an array of strings. A document is
indexed with relevancy_tags = ["a", "b","c","d"]. I want to return the
document if the query is "a". I've tried using the term and terms filter
but they don't return any results.

Help :frowning: ?

Mapping:

"relevancy_tags" : {

      "type" : "string"

    },

--
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/fbb77163-246d-46b4-ba4d-25e98acdd308%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

In 0.90, we use english stopwords by default.

"A" is a stopword.

I guess it´s your issue.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 17 janv. 2014 à 03:44, Karan Verma karan@healthtap.com a écrit :

Hi

My field relevancy_tags is index as an array of strings. A document is indexed with relevancy_tags = ["a", "b","c","d"]. I want to return the document if the query is "a". I've tried using the term and terms filter but they don't return any results.

Help :frowning: ?

Mapping:

"relevancy_tags" : {

      "type" : "string"

    },

--
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/fbb77163-246d-46b4-ba4d-25e98acdd308%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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/0A41FF2C-E8D6-4893-B7C0-C40B55528978%40pilato.fr.
For more options, visit https://groups.google.com/groups/opt_out.

Hi David

It is not a stopword issue, I just used the alphabets to simplify my
question on this forum. Do you think that the term/terms filter would match
the document?

Here is the query I am making. A lot of documents have relevancy_tags
as Psychiatry but none of them match when I use the explain API.

{
"fields": ,
"explain": true,
"query": {
"custom_filters_score": {
"query": {
"bool": {
"must": [
{
"term": {
"show_in_work_queue": {
"term": true
}
}
}
]
}
},
"filters": [
{
"filter": {
"term": {
"verified_answers_count": {
"term": 0
}
}
},
"boost": 256
},
{
"filter": {
"term": {
"waiting_for_second_opinion": {
"term": true
}
}
},
"boost": 128
},
{
"filter": {
"term": {
"relevancy_tags": {
"term": "Psychiatry"
}
}
},
"boost": 256
},
{
"filter": {
"terms": {
"relevancy_tags": [
"Psychiatry",
"Holistic Medicine",
"Undersea and Hyperbaric Medicine"
]
}
},
"boost": 16
},
{
"filter": {
"terms": {
"relevancy_tags": [
"Child Psychiatry",
"Geriatric Psychiatry",
"ADHD and Autism",
"Addiction Medicine",
"Clinical Psychology"
]
}
},
"boost": 4
},
{
"filter": {
"terms": {
"relevancy_tags": [
"Child Psychiatry",
"Geriatric Psychiatry",
"ADHD and Autism",
"Addiction Medicine",
"Clinical Psychology"
]
}
},
"boost": 2
}
],
"score_mode": "total"
}
},
"size": 30,
"from": 0
}

On Thu, Jan 16, 2014 at 10:10 PM, David Pilato david@pilato.fr wrote:

In 0.90, we use english stopwords by default.

"A" is a stopword.

I guess it´s your issue.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 17 janv. 2014 à 03:44, Karan Verma karan@healthtap.com a écrit :

Hi

My field relevancy_tags is index as an array of strings. A document is
indexed with relevancy_tags = ["a", "b","c","d"]. I want to return the
document if the query is "a". I've tried using the term and terms filter
but they don't return any results.

Help :frowning: ?

Mapping:

"relevancy_tags" : {

      "type" : "string"

    },

--
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/fbb77163-246d-46b4-ba4d-25e98acdd308%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/Iw6rMaP7BW0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/0A41FF2C-E8D6-4893-B7C0-C40B55528978%40pilato.fr
.

For more options, visit https://groups.google.com/groups/opt_out.

--
Best,
Karan

Life saving Ninja & Software Engineer

Karan pronounced Ka (http://tiny.cc/0lu61w) + Run

--
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/CAGX3c4Fojmp4EK4sVVNe%2BDUvwh%2BE7KtASoF8gAca_Qnm0GW6HQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Use match queries or lowercase your search.

But it would be easier to answer with a simple full curl recreation as a Gist.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 17 janv. 2014 à 19:38, Karan Verma karan@healthtap.com a écrit :

Psychiatry

--
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/317AE917-EAA4-4743-8BC9-B9621298CFCF%40pilato.fr.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks David, making it a lowercase gave me the desired result. I guess
because it not analyzed was not set in the mapping it was being converted
it to lowercase before matching.

On Fri, Jan 17, 2014 at 10:45 AM, David Pilato david@pilato.fr wrote:

Use match queries or lowercase your search.

But it would be easier to answer with a simple full curl recreation as a
Gist.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 17 janv. 2014 à 19:38, Karan Verma karan@healthtap.com a écrit :

Psychiatry

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/Iw6rMaP7BW0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/317AE917-EAA4-4743-8BC9-B9621298CFCF%40pilato.fr
.
For more options, visit https://groups.google.com/groups/opt_out.

--
Best,
Karan

Life saving Ninja & Software Engineer

Karan pronounced Ka (http://tiny.cc/0lu61w) + Run

--
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/CAGX3c4Fd6RBgdK3eTDx9EJ-gEHx9be4nOh%2Bs3fSVA262_eLmcg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Exactly termQuery is not analyzed so its compared as is to the inverted index.
Match query is analyzed.

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

Le 17 janvier 2014 at 20:12:10, Karan Verma (karan@healthtap.com) a écrit:

Thanks David, making it a lowercase gave me the desired result. I guess because it not analyzed was not set in the mapping it was being converted it to lowercase before matching.

On Fri, Jan 17, 2014 at 10:45 AM, David Pilato david@pilato.fr wrote:
Use match queries or lowercase your search.

But it would be easier to answer with a simple full curl recreation as a Gist.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 17 janv. 2014 à 19:38, Karan Verma karan@healthtap.com a écrit :

Psychiatry

--
You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elasticsearch/Iw6rMaP7BW0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/317AE917-EAA4-4743-8BC9-B9621298CFCF%40pilato.fr.
For more options, visit https://groups.google.com/groups/opt_out.

--
Best,
Karan

Life saving Ninja & Software Engineer

Karan pronounced Ka (http://tiny.cc/0lu61w) + Run

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/CAGX3c4Fd6RBgdK3eTDx9EJ-gEHx9be4nOh%2Bs3fSVA262_eLmcg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.52d99231.1f48eaa1.dc5%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/groups/opt_out.