Term query question

I created some random data to test search.

When it do I match query, it works fine.
curl -XGET
'http://ec2-54-224-40-21.compute-1.amazonaws.com:9200/test/test/_search?pretty=true'
-d '{query:{"match": {"field1":"PITU"}}}'
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 10.21034,
"hits" : [ {
"_index" : "test",
"_type" : "test",
"_id" : "78116",
"_score" : 10.21034, "_source" : {"id":78115,"field1":"PITU","field2":"DKBV
GOAT","field3":"JXIX FPOZ WZIV","field4":"GQWZ AFHU VMJF
AENE","field5":"BFEJ BEEX CHNM VCEL
NALA","date":"2013-03-20T02:50:57.927Z","site":"A"}
} ]
}

but when I try the same thing with a term query, I don't get any results.
curl -XGET
'http://ec2-54-224-40-21.compute-1.amazonaws.com:9200/test/test/_search?pretty=true'
-d '{query:{"term": {"field1":"PITU"}}}'
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}

The strangest part is that when I change to search value to all lowercase,
I get a valid result back
curl -XGET
'http://ec2-54-224-40-21.compute-1.amazonaws.com:9200/test/test/_search?pretty=true'
-d '{query:{"term": {"field1":"pitu"}}}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 10.21034,
"hits" : [ {
"_index" : "test",
"_type" : "test",
"_id" : "78116",
"_score" : 10.21034, "_source" : {"id":78115,"field1":"PITU","field2":"DKBV
GOAT","field3":"JXIX FPOZ WZIV","field4":"GQWZ AFHU VMJF
AENE","field5":"BFEJ BEEX CHNM VCEL
NALA","date":"2013-03-20T02:50:57.927Z","site":"A"}
} ]
}

Is this the expected behavior?

Also, I am still not sure what the difference between term/match/field
query is. Any help (or links to related questions) would be appreciated.

Thanks!

--
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 are not analyzed. The term being searched for must match
exactly the term that was indexed. Without knowing your mapping, I
am assuming that field1 is analyzed by the standard analyzer, which means
the tokens are lowercased before being indexed.

Analysis is a Lucene-level concept (actually text analysis in general), so
you can better understand analyzed/non-analyzed concepts by reading about
Lucene:
http://lucene.apache.org/core/4_2_0/core/org/apache/lucene/analysis/package-summary.html

NOTE: I know that Elasticsearch documentation is being worked on, but this
core concept needs to be addressed up front.

--
Ivan

On Wed, Mar 20, 2013 at 2:49 PM, Fish Tastic whoisbingo@gmail.com wrote:

I created some random data to test search.

When it do I match query, it works fine.
curl -XGET '
http://ec2-54-224-40-21.compute-1.amazonaws.com:9200/test/test/_search?pretty=true'
-d '{query:{"match": {"field1":"PITU"}}}'
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 10.21034,
"hits" : [ {
"_index" : "test",
"_type" : "test",
"_id" : "78116",
"_score" : 10.21034, "_source" : {"id":78115,"field1":"PITU","field2":"DKBV
GOAT","field3":"JXIX FPOZ WZIV","field4":"GQWZ AFHU VMJF
AENE","field5":"BFEJ BEEX CHNM VCEL
NALA","date":"2013-03-20T02:50:57.927Z","site":"A"}
} ]
}

but when I try the same thing with a term query, I don't get any results.
curl -XGET '
http://ec2-54-224-40-21.compute-1.amazonaws.com:9200/test/test/_search?pretty=true'
-d '{query:{"term": {"field1":"PITU"}}}'
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" :
}

The strangest part is that when I change to search value to all lowercase,
I get a valid result back
curl -XGET '
http://ec2-54-224-40-21.compute-1.amazonaws.com:9200/test/test/_search?pretty=true'
-d '{query:{"term": {"field1":"pitu"}}}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 10.21034,
"hits" : [ {
"_index" : "test",
"_type" : "test",
"_id" : "78116",
"_score" : 10.21034, "_source" : {"id":78115,"field1":"PITU","field2":"DKBV
GOAT","field3":"JXIX FPOZ WZIV","field4":"GQWZ AFHU VMJF
AENE","field5":"BFEJ BEEX CHNM VCEL
NALA","date":"2013-03-20T02:50:57.927Z","site":"A"}
} ]
}

Is this the expected behavior?

Also, I am still not sure what the difference between term/match/field
query is. Any help (or links to related questions) would be appreciated.

Thanks!

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

Thanks, that's kinda what I was thinking as well. I didn't use any special
analyzer so everything probably just turned lowercased. The documentation
mentioned about not_analyzed but it wasn't detailed enough.

Here is my mapping:

curl -XGET
'http://ec2-54-224-40-21.compute-1.amazonaws.com:9200/test/test/_mapping?pretty=true'
{
"test" : {
"properties" : {
"date" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"field1" : {
"type" : "string"
},
"field2" : {
"type" : "string"
},
"field3" : {
"type" : "string"
},
"field4" : {
"type" : "string"
},
"field5" : {
"type" : "string"
},
"id" : {
"type" : "long"
},
"site" : {
"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.
For more options, visit https://groups.google.com/groups/opt_out.

If you want an exact match, then set the field as non_analyzed and use a
term query. In other words, only use a term query on non_analyzed fields
(the default for numerical fields).

It is up to your use case if a field should do an exact match. If you
require both, look into multi fields:

--
Ivan

On Wed, Mar 20, 2013 at 3:08 PM, Fish Tastic whoisbingo@gmail.com wrote:

Thanks, that's kinda what I was thinking as well. I didn't use any special
analyzer so everything probably just turned lowercased. The documentation
mentioned about not_analyzed but it wasn't detailed enough.

Here is my mapping:

curl -XGET '
http://ec2-54-224-40-21.compute-1.amazonaws.com:9200/test/test/_mapping?pretty=true
'
{
"test" : {
"properties" : {
"date" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"field1" : {
"type" : "string"
},
"field2" : {
"type" : "string"
},
"field3" : {
"type" : "string"
},
"field4" : {
"type" : "string"
},
"field5" : {
"type" : "string"
},
"id" : {
"type" : "long"
},
"site" : {
"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.
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.

as far as i know,if you didn't explicitly set the index parameter of a specific filed to "no" or "non_analyzed",by default, it's analyzed.

I created some random data to test search.

When it do I match query, it works fine.
curl -XGET
'http://ec2-54-224-40-21.compute-1.amazonaws.com:9200/test/test/_search?pretty=true'
-d '{query:{"match": {"field1":"PITU"}}}'
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 10.21034,
"hits" : [ {
"_index" : "test",
"_type" : "test",
"_id" : "78116",
"_score" : 10.21034, "_source" : {"id":78115,"field1":"PITU","field2":"DKBV
GOAT","field3":"JXIX FPOZ WZIV","field4":"GQWZ AFHU VMJF
AENE","field5":"BFEJ BEEX CHNM VCEL
NALA","date":"2013-03-20T02:50:57.927Z","site":"A"}
} ]
}

but when I try the same thing with a term query, I don't get any results.
curl -XGET
'http://ec2-54-224-40-21.compute-1.amazonaws.com:9200/test/test/_search?pretty=true'
-d '{query:{"term": {"field1":"PITU"}}}'
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}

The strangest part is that when I change to search value to all lowercase,
I get a valid result back
curl -XGET
'http://ec2-54-224-40-21.compute-1.amazonaws.com:9200/test/test/_search?pretty=true'
-d '{query:{"term": {"field1":"pitu"}}}'
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 10.21034,
"hits" : [ {
"_index" : "test",
"_type" : "test",
"_id" : "78116",
"_score" : 10.21034, "_source" : {"id":78115,"field1":"PITU","field2":"DKBV
GOAT","field3":"JXIX FPOZ WZIV","field4":"GQWZ AFHU VMJF
AENE","field5":"BFEJ BEEX CHNM VCEL
NALA","date":"2013-03-20T02:50:57.927Z","site":"A"}
} ]
}

Is this the expected behavior?

Also, I am still not sure what the difference between term/match/field
query is. Any help (or links to related questions) would be appreciated.

Thanks!

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