# Querying for field Id (not \_id) does not work

**URL:** https://discuss.elastic.co/t/querying-for-field-id-not--id-does-not-work/16978
**Category:** Elasticsearch
**Created:** [April 12, 2014, 7:31pm UTC](https://discuss.elastic.co/t/querying-for-field-id-not--id-does-not-work/16978 "2014-04-12T19:31:37Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Seif\_Lotfy](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Seif\_Lotfy](https://discuss.elastic.co/u/Seif_Lotfy)
#### Post date: [April 12, 2014, 7:31pm UTC](https://discuss.elastic.co/t/querying-for-field-id-not--id-does-not-work/16978/1 "2014-04-12T19:31:37Z")

</div>

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

---

<div class="post-metadata">

### Author: ![eunever32](https://avatars.discourse-cdn.com/v4/letter/e/e68b1a/32.png) [@eunever32](https://discuss.elastic.co/u/eunever32)
#### Post date: [April 13, 2014, 7:42pm UTC](https://discuss.elastic.co/t/querying-for-field-id-not--id-does-not-work/16978/2 "2014-04-13T19:42:28Z")

</div>

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

---

<div class="post-metadata">

### Author: ![eunever32](https://avatars.discourse-cdn.com/v4/letter/e/e68b1a/32.png) [@eunever32](https://discuss.elastic.co/u/eunever32)
#### Post date: [April 14, 2014, 5:51pm UTC](https://discuss.elastic.co/t/querying-for-field-id-not--id-does-not-work/16978/3 "2014-04-14T17:51:05Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 1:35am UTC](https://discuss.elastic.co/t/querying-for-field-id-not--id-does-not-work/16978/4 "2017-07-06T01:35:54Z")

</div>


