Querying for field Id (not _id) does not work


(Seif Lotfy) #1

I am storing my documents as follows:

{
_index: "crash-instances-app1"
_type: "crash"
_id: "LmSAjgrvSry2ltvsxAVqcw"
_source: {
OsInfo: "osinfo1"
Exception: "exception1"
Description: "desc1"
AppId: "app1"
StackTraces: "stack1"
Timestamp: 1395751604
DeviceInfo: "device91"
Id: "Id-9829"
ClientId: "client69"
CrashId: "crash29"
}
}

querying via

{
"query": {
"term": {
"AppId": "app1"
}
}
}

works great and i get this document back, yet querying via

{
"query": {
"term": {
"Id": "Id-9829"
}
}
}

return nothing.

--
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/6fc839a0-c5e8-45b6-bd49-043c36070455%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(eunever32) #2

Hey Seif,

I had this problem myself and I think it catches a lot of people.

The problem is because "term query" is not analyzed.

So you need something like "query_string" or match query to make your query
analyzed.

Cheers.

On Saturday, April 12, 2014 8:31:37 PM UTC+1, Seif Lotfy wrote:

I am storing my documents as follows:

{
_index: "crash-instances-app1"
_type: "crash"
_id: "LmSAjgrvSry2ltvsxAVqcw"
_source: {
OsInfo: "osinfo1"
Exception: "exception1"
Description: "desc1"
AppId: "app1"
StackTraces: "stack1"
Timestamp: 1395751604
DeviceInfo: "device91"
Id: "Id-9829"
ClientId: "client69"
CrashId: "crash29"
}
}

querying via

{
"query": {
"term": {
"AppId": "app1"
}
}
}

works great and i get this document back, yet querying via

{
"query": {
"term": {
"Id": "Id-9829"
}
}
}

return nothing.

--
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/c1af5d47-29f5-42ab-a6a8-ddb8278115e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(eunever32) #3

!! Hey filter/ moderator, please do not delete my post!!

Seif,

What is happening is that you need to be consistent between indexing and
searching in terms of "analyzed"
The problem happens because your search "Id": "Id-9829" is case sensitive
in the Id-9829 bit.
One fix is to search on "id-9829"
Another is to create a mapping so that Id is "not_analyzed" then search on
"Id-9829"
Another fix is to use the query: query_string or the query: match. They
will support lucene type matching strings.

Cheers.

On Saturday, April 12, 2014 8:31:37 PM UTC+1, Seif Lotfy wrote:

I am storing my documents as follows:

{
_index: "crash-instances-app1"
_type: "crash"
_id: "LmSAjgrvSry2ltvsxAVqcw"
_source: {
OsInfo: "osinfo1"
Exception: "exception1"
Description: "desc1"
AppId: "app1"
StackTraces: "stack1"
Timestamp: 1395751604
DeviceInfo: "device91"
Id: "Id-9829"
ClientId: "client69"
CrashId: "crash29"
}
}

querying via

{
"query": {
"term": {
"AppId": "app1"
}
}
}

works great and i get this document back, yet querying via

{
"query": {
"term": {
"Id": "Id-9829"
}
}
}

return nothing.

--
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/fdc2a8e8-b9f6-4b37-98a4-d5ee21cb26ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #4