Term query support two separate letters?

Hi,

Would like to know whether term query support two separate letters as i
can't find it in the document of any indication (if not any alternative as
i need exact word matching). I have the following query :

{
"query": {

  •    "filtered" : {*
    
  •     "query" : {*
    
  •           "term" : {*
    
  •               "USER_ID" : "2"*
    
  •            }*
    
  •        },*
    
  •        "filter" : {               *
    
  •          "bool" : {*
    
  •                    "must" : [*
    
  •                         { "term" : { "CAT_ID" : "131"}}, 
    

//ContentType *

  •                         { "term" : { "CAT_NAME" : "latest games"}} 
    

//Genre *

  •                        ]*
    
  •                   } *
    
  •        }*
    
  •    }*
    
  • }*
    }

and it doesn't return result however if the cat_name was latest then it
return.

The document have the following :

"CAT_NAME": [
"Ala Carte",
"OffSeason",
"Latest Games",
"Adventure"
],

--
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.

Term queries terms are not analyzed, so they work best against fields that
are not analyzed. If you did not specify the CAT_NAME field as not_analyzed
(or used a keyword analyzer), then the standard analyzer will be used and
the value will be split in multiple tokens. Change the mapping for that
field to be not_analyzed and re-index your content.

--
Ivan

On Sun, Aug 4, 2013 at 9:16 PM, cyrilforce cheehoo84@gmail.com wrote:

Hi,

Would like to know whether term query support two separate letters as i
can't find it in the document of any indication (if not any alternative as
i need exact word matching). I have the following query :

{
"query": {

  •    "filtered" : {*
    
  •     "query" : {*
    
  •           "term" : {*
    
  •               "USER_ID" : "2"*
    
  •            }*
    
  •        },*
    
  •        "filter" : {               *
    
  •          "bool" : {*
    
  •                    "must" : [*
    
  •                         { "term" : { "CAT_ID" : "131"}},
    

//ContentType *

  •                         { "term" : { "CAT_NAME" : "latest games"}}
    

//Genre *

  •                        ]*
    
  •                   } *
    
  •        }*
    
  •    }*
    
  • }*
    }

and it doesn't return result however if the cat_name was latest then it
return.

The document have the following :

"CAT_NAME": [
"Ala Carte",
"OffSeason",
"Latest Games",
"Adventure"
],

--
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.

I add to Ivan's answer that for you use case as you query your term with lower case, you should use a keyword tokenizer + a lowercase filter in a custom analyzer and apply it to your field as described by Ivan.

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

Le 5 août 2013 à 07:26, Ivan Brusic ivan@brusic.com a écrit :

Term queries terms are not analyzed, so they work best against fields that are not analyzed. If you did not specify the CAT_NAME field as not_analyzed (or used a keyword analyzer), then the standard analyzer will be used and the value will be split in multiple tokens. Change the mapping for that field to be not_analyzed and re-index your content.

--
Ivan

On Sun, Aug 4, 2013 at 9:16 PM, cyrilforce cheehoo84@gmail.com wrote:

Hi,

Would like to know whether term query support two separate letters as i can't find it in the document of any indication (if not any alternative as i need exact word matching). I have the following query :

{
"query": {
"filtered" : {
"query" : {
"term" : {
"USER_ID" : "2"
}
},
"filter" : {
"bool" : {
"must" : [
{ "term" : { "CAT_ID" : "131"}}, //ContentType
{ "term" : { "CAT_NAME" : "latest games"}} //Genre
]
}
}
}
}
}

and it doesn't return result however if the cat_name was latest then it return.

The document have the following :

"CAT_NAME": [
"Ala Carte",
"OffSeason",
"Latest Games",
"Adventure"
],

--
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.

--
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.

Hi Ivan,

I tried with some sample as following :

{
"tweet" : {
"properties" : {
"message" : {"type" : "string", "index" : "not_analyzed"}

    },
    "ignore_conflicts" : "true"
}

}

I not sure whether the ignore_conflicts parameter is in the right place or
not. But anyway with or without it still it will produce errors : {
"error": "MergeMappingException[Merge failed with failures {[mapper
[message] has different index values, mapper [message] has different
tokenize values, mapper [message] has different index_analyzer]}]",
"status": 400
}

Thanks.

Cyril

On Mon, Aug 5, 2013 at 1:26 PM, Ivan Brusic ivan@brusic.com wrote:

Term queries terms are not analyzed, so they work best against fields that
are not analyzed. If you did not specify the CAT_NAME field as not_analyzed
(or used a keyword analyzer), then the standard analyzer will be used and
the value will be split in multiple tokens. Change the mapping for that
field to be not_analyzed and re-index your content.

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

--
Ivan

On Sun, Aug 4, 2013 at 9:16 PM, cyrilforce cheehoo84@gmail.com wrote:

Hi,

Would like to know whether term query support two separate letters as i
can't find it in the document of any indication (if not any alternative as
i need exact word matching). I have the following query :

{
"query": {

  •    "filtered" : {*
    
  •     "query" : {*
    
  •           "term" : {*
    
  •               "USER_ID" : "2"*
    
  •            }*
    
  •        },*
    
  •        "filter" : {               *
    
  •          "bool" : {*
    
  •                    "must" : [*
    
  •                         { "term" : { "CAT_ID" : "131"}},
    

//ContentType *

  •                         { "term" : { "CAT_NAME" : "latest games"}}
    

//Genre *

  •                        ]*
    
  •                   } *
    
  •        }*
    
  •    }*
    
  • }*
    }

and it doesn't return result however if the cat_name was latest then it
return.

The document have the following :

"CAT_NAME": [
"Ala Carte",
"OffSeason",
"Latest Games",
"Adventure"
],

--
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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/RTS09HzWG-M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Regards,

Chee Hoo

--
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 can not update your mapping.
Remove the old one. It will remove your docs BTW.

And create a new one.

HTH

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

Le 5 août 2013 à 10:19, chee hoo lum cheehoo84@gmail.com a écrit :

Hi Ivan,

I tried with some sample as following :

{
"tweet" : {
"properties" : {
"message" : {"type" : "string", "index" : "not_analyzed"}

    },
    "ignore_conflicts" : "true"
}

}

I not sure whether the ignore_conflicts parameter is in the right place or not. But anyway with or without it still it will produce errors : {
"error": "MergeMappingException[Merge failed with failures {[mapper [message] has different index values, mapper [message] has different tokenize values, mapper [message] has different index_analyzer]}]",
"status": 400
}

Thanks.

Cyril

On Mon, Aug 5, 2013 at 1:26 PM, Ivan Brusic ivan@brusic.com wrote:

Term queries terms are not analyzed, so they work best against fields that are not analyzed. If you did not specify the CAT_NAME field as not_analyzed (or used a keyword analyzer), then the standard analyzer will be used and the value will be split in multiple tokens. Change the mapping for that field to be not_analyzed and re-index your content.

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

--
Ivan

On Sun, Aug 4, 2013 at 9:16 PM, cyrilforce cheehoo84@gmail.com wrote:

Hi,

Would like to know whether term query support two separate letters as i can't find it in the document of any indication (if not any alternative as i need exact word matching). I have the following query :

{
"query": {
"filtered" : {
"query" : {
"term" : {
"USER_ID" : "2"
}
},
"filter" : {
"bool" : {
"must" : [
{ "term" : { "CAT_ID" : "131"}}, //ContentType
{ "term" : { "CAT_NAME" : "latest games"}} //Genre
]
}
}
}
}
}

and it doesn't return result however if the cat_name was latest then it return.

The document have the following :

"CAT_NAME": [
"Ala Carte",
"OffSeason",
"Latest Games",
"Adventure"
],

--
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 a topic in the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elasticsearch/RTS09HzWG-M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Regards,

Chee Hoo

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.

Hi David,

Thanks. But i m not gonna remove it cause that been administrate by the
another guy. In spite of that i could achieve what i wanted with the
following query :

{
"query": {

  •    "filtered" : {*
    
  •     "query" : {*
    
  •           "term" : {*
    
  •               "USER_ID" : "2"*
    
  •            }*
    
  •        },*
    
  •         "filter" : {  *
    
  •             "query" : {             *
    
  •                   "bool" : {*
    
  •                        "must" : [*
    
  •                              { "term" : { "CAT_ID" : "131"}}, *
    
  •                              { "match" : { "CAT_NAME" : { "query" :
    

"Top 10", "operator" : "and" }}} *

  •                          ]*
    
  •                   } *
    
  •           }*
    
  •        }*
    
  •    }*
    
  • }*
    }

Any shortcoming you could foresee ? Thanks anyway enlightenment on the
mapping.

Cyril

On Mon, Aug 5, 2013 at 4:31 PM, David Pilato david@pilato.fr wrote:

You can not update your mapping.
Remove the old one. It will remove your docs BTW.

And create a new one.

HTH

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

Le 5 août 2013 à 10:19, chee hoo lum cheehoo84@gmail.com a écrit :

Hi Ivan,

I tried with some sample as following :

{
"tweet" : {
"properties" : {
"message" : {"type" : "string", "index" : "not_analyzed"}

    },
    "ignore_conflicts" : "true"
}

}

I not sure whether the ignore_conflicts parameter is in the right place or
not. But anyway with or without it still it will produce errors : {
"error": "MergeMappingException[Merge failed with failures {[mapper
[message] has different index values, mapper [message] has different
tokenize values, mapper [message] has different index_analyzer]}]",
"status": 400
}

Thanks.

Cyril

On Mon, Aug 5, 2013 at 1:26 PM, Ivan Brusic ivan@brusic.com wrote:

Term queries terms are not analyzed, so they work best against fields
that are not analyzed. If you did not specify the CAT_NAME field as
not_analyzed (or used a keyword analyzer), then the standard analyzer will
be used and the value will be split in multiple tokens. Change the mapping
for that field to be not_analyzed and re-index your content.

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

--
Ivan

On Sun, Aug 4, 2013 at 9:16 PM, cyrilforce cheehoo84@gmail.com wrote:

Hi,

Would like to know whether term query support two separate letters as i
can't find it in the document of any indication (if not any alternative as
i need exact word matching). I have the following query :

{
"query": {

  •    "filtered" : {*
    
  •     "query" : {*
    
  •           "term" : {*
    
  •               "USER_ID" : "2"*
    
  •            }*
    
  •        },*
    
  •        "filter" : {               *
    
  •          "bool" : {*
    
  •                    "must" : [*
    
  •                         { "term" : { "CAT_ID" : "131"}},
    

//ContentType *

  •                         { "term" : { "CAT_NAME" : "latest games"}}
    

//Genre *

  •                        ]*
    
  •                   } *
    
  •        }*
    
  •    }*
    
  • }*
    }

and it doesn't return result however if the cat_name was latest then it
return.

The document have the following :

"CAT_NAME": [
"Ala Carte",
"OffSeason",
"Latest Games",
"Adventure"
],

--
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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/RTS09HzWG-M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Regards,

Chee Hoo

--
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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/RTS09HzWG-M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Regards,

Chee Hoo

--
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.