match vs term query

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

match vs term query

paul

mapping is
  • plan
    {
    • type"string"
    }

data:
  • planNot 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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: match vs term query

dadoonet
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


Le 21 novembre 2013 at 10:01:50, paul ([hidden email]) a écrit:


mapping is
  • plan
    {
    • type"string"
    }

data:
  • planNot 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 [hidden email].
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: match vs term query

paul

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


Le 21 novembre 2013 at 10:01:50, paul (<a href="javascript:" target="_blank" gdf-obfuscated-mailto="QPjw0P28Vu8J">avinas...@...) a écrit:


mapping is
  • plan
    {
    • type"string"
    }

data:
  • planNot 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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="QPjw0P28Vu8J">elasticsearc...@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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.