Match vs term query


(paul) #1

mapping is

  • plan:
    {
    • type: "string"
      }

data:

  • plan: Not Available
  • plan: Available
  • plan: Not Available
  • plan: Not Available

The below query returns results.
"query": {
"match": {
"plan": "Not Available"
}
}

If i change match to term i get zero results, though the terms are present
in data.
"query": {
"term": {
"plan": "Not Available"
}
}

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


(David Pilato) #2

Because your analyzer for that field is the standard one.
It index you field « Not Available » into « available ».

You need to use a keyword analyzer or not analyze at all the field if you want to use the TermQuery here.

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

Le 21 novembre 2013 at 10:01:50, paul (avinashpaul85@gmail.com) a écrit:

mapping is
plan: {
type: "string"
}

data:
plan: Not Available
plan: Available
plan: Not Available
plan: Not Available

The below query returns results.
"query": {
"match": {
"plan": "Not Available"
}
}

If i change match to term i get zero results, though the terms are present in data.
"query": {
"term": {
"plan": "Not Available"
}
}

--
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.
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.
For more options, visit https://groups.google.com/groups/opt_out.


(paul) #3

thank you for the clarification , after the changes it works ,one
clarification the standard analyzer converts it to lower case and removes
the "Not".

Regards
Paul

On Thursday, 21 November 2013 14:58:47 UTC+5:30, David Pilato wrote:

Because your analyzer for that field is the standard one.
It index you field « Not Available » into « available ».

You need to use a keyword analyzer or not analyze at all the field if you
want to use the TermQuery here.

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

Le 21 novembre 2013 at 10:01:50, paul (avinas...@gmail.com <javascript:>)
a écrit:

mapping is

  • plan:
    {
    • type: "string"
      }

data:

  • plan: Not Available
  • plan: Available
  • plan: Not Available
  • plan: Not Available

The below query returns results.
"query": {
"match": {
"plan": "Not Available"
}
}

If i change match to term i get zero results, though the terms are present
in data.
"query": {
"term": {
"plan": "Not Available"
}
}

--
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:>.
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.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #4