# Bool filter is not searching field content

**URL:** https://discuss.elastic.co/t/bool-filter-is-not-searching-field-content/14998
**Category:** Elasticsearch
**Created:** [December 23, 2013, 1:24pm UTC](https://discuss.elastic.co/t/bool-filter-is-not-searching-field-content/14998 "2013-12-23T13:24:18Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Bruno\_Galindro\_da\_Co](https://avatars.discourse-cdn.com/v4/letter/b/59ef9b/32.png) [@Bruno\_Galindro\_da\_Co](https://discuss.elastic.co/u/Bruno_Galindro_da_Co)
#### Post date: [December 23, 2013, 1:24pm UTC](https://discuss.elastic.co/t/bool-filter-is-not-searching-field-content/14998/1 "2013-12-23T13:24:18Z")

</div>

This query returns 7 itens:

curl -XGET "[http://localhost:9200/modmine/\_search](http://localhost:9200/modmine/_search)" -d'  
{  
"query": {  
"filtered": {  
"query": {  
"match\_all": {}  
},  
"filter": {  
"bool": {  
"must": [  
{  
"type": {  
"value": "sequencefeature"  
}  
}  
],  
"must": [  
{  
"term": {  
"sequenceid": "179781000"  
}  
}  
]  
}  
}  
}  
}  
}'

Piece of result:

"hits": {  
"total": 7,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "modmine",  
"\_type": "sequencefeature",  
"\_id": "111",  
"\_score": 1,  
"_source": {  
"sequenceid": 179781000,  
"name": null,  
"symbol": null,  
"scoretype":  
"RNAseq\_\_\_L4\_soma\_JK1107\_no\_DNaseI\_genelets\_revised\_100320:L4\_soma\_JK1107\_no\_DNaseI"  
,  
"note": null,  
"organismid": 11000000,  
"length": 2,  
"score": null,  
"predictionstatus": null,  
"chromosomelocationid": 102573059,  
"chromosomeid": 11000003,  
"secondaryidentifier":  
"RNAseq\_\_\_L4\_soma\_JK1107\_no\_DNaseI\_genelets\_revised\_100320.exon\_I\_10074047\_10074048_-_wb170"  
,  
"cytolocation": null,  
"scoreprotocolid": 76003281,  
"class": "org.intermine.model.bio.Exon",  
"id": 102573058,  
"primaryidentifier":  
"RNAseq\_\_\_L4\_soma\_JK1107\_no\_DNaseI\_genelets\_revised\_100320.exon\_I\_10074047\_10074048_-\_wb170"  
,  
"sequenceontologytermid": 1000002  
}  
},

If I modify the query to search for _id_ field instead of _sequenceid_, no  
results are displayed. Why?

curl -XGET "[http://localhost:9200/modmine/\_search](http://localhost:9200/modmine/_search)" -d'  
{  
"query": {  
"filtered": {  
"query": {  
"match\_all": {}  
},  
"filter": {  
"bool": {  
"must": [  
{  
"type": {  
"value": "sequencefeature"  
}  
}  
],  
"must": [  
{  
"term": {  
"id": "102573058"  
}  
}  
]  
}  
}  
}  
}  
}'

{  
"took": 2,  
"timed\_out": false,  
"\_shards": {  
"total": 2,  
"successful": 2,  
"failed": 0  
},  
"hits": {  
"total": 0,  
"max\_score": null,  
"hits": []  
}  
}

--  
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/0f86ce39-f622-48bc-9d4f-54f07d8d0a59%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0f86ce39-f622-48bc-9d4f-54f07d8d0a59%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [December 23, 2013, 1:37pm UTC](https://discuss.elastic.co/t/bool-filter-is-not-searching-field-content/14998/2 "2013-12-23T13:37:20Z")

</div>

Is it your actual query?  
Asking this because I can't see `type` field in your docs. Wondering how 1st query could match?

Any chance that you create a full curl recreation and gist it?

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 23 décembre 2013 at 14:24:23, Bruno Galindro da Costa ([bruno.galindro@gmail.com](mailto:bruno.galindro@gmail.com)) a écrit:

This query returns 7 itens:

curl -XGET "[http://localhost:9200/modmine/\_search](http://localhost:9200/modmine/_search)" -d'  
{  
"query": {  
"filtered": {  
"query": {  
"match\_all": {}  
},  
"filter": {  
"bool": {  
"must": [  
{  
"type": {  
"value": "sequencefeature"  
}  
}  
],  
"must": [  
{  
"term": {  
"sequenceid": "179781000"  
}  
}  
]  
}  
}  
}  
}  
}'

Piece of result:

"hits": {  
"total": 7,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "modmine",  
"\_type": "sequencefeature",  
"\_id": "111",  
"\_score": 1,  
"_source": {  
"sequenceid": 179781000,  
"name": null,  
"symbol": null,  
"scoretype": "RNAseq\_\_\_L4\_soma\_JK1107\_no\_DNaseI\_genelets\_revised\_100320:L4\_soma\_JK1107\_no\_DNaseI",  
"note": null,  
"organismid": 11000000,  
"length": 2,  
"score": null,  
"predictionstatus": null,  
"chromosomelocationid": 102573059,  
"chromosomeid": 11000003,  
"secondaryidentifier": "RNAseq\_\_\_L4\_soma\_JK1107\_no\_DNaseI\_genelets\_revised\_100320.exon\_I\_10074047\_10074048_-_wb170",  
"cytolocation": null,  
"scoreprotocolid": 76003281,  
"class": "org.intermine.model.bio.Exon",  
"id": 102573058,  
"primaryidentifier": "RNAseq\_\_\_L4\_soma\_JK1107\_no\_DNaseI\_genelets\_revised\_100320.exon\_I\_10074047\_10074048_-\_wb170",  
"sequenceontologytermid": 1000002  
}  
},

If I modify the query to search for id field instead of sequenceid, no results are displayed. Why?

curl -XGET "[http://localhost:9200/modmine/\_search](http://localhost:9200/modmine/_search)" -d'  
{  
"query": {  
"filtered": {  
"query": {  
"match\_all": {}  
},  
"filter": {  
"bool": {  
"must": [  
{  
"type": {  
"value": "sequencefeature"  
}  
}  
],  
"must": [  
{  
"term": {  
"id": "102573058"  
}  
}  
]  
}  
}  
}  
}  
}'

{  
"took": 2,  
"timed\_out": false,  
"\_shards": {  
"total": 2,  
"successful": 2,  
"failed": 0  
},  
"hits": {  
"total": 0,  
"max\_score": null,  
"hits": []  
}  
}

--  
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/0f86ce39-f622-48bc-9d4f-54f07d8d0a59%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0f86ce39-f622-48bc-9d4f-54f07d8d0a59%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/etPan.52b83c90.100f8fca.111%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.52b83c90.100f8fca.111%40MacBook-Air-de-David.local).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Bruno\_Galindro\_da\_Co](https://avatars.discourse-cdn.com/v4/letter/b/59ef9b/32.png) [@Bruno\_Galindro\_da\_Co](https://discuss.elastic.co/u/Bruno_Galindro_da_Co)
#### Post date: [December 23, 2013, 3:38pm UTC](https://discuss.elastic.co/t/bool-filter-is-not-searching-field-content/14998/3 "2013-12-23T15:38:30Z")

</div>

Is it your actual query?  
Yes

Any chance that you create a full curl recreation and gist it?  
Not understood sorry...

Asking this because I can't see `type` field in your docs. Wondering how  
1st query could match?  
Yes, it does not have a "type" field.

What I need to do is a query filtering by the id field (not \_id) and the  
mapping type must be _sequencefeature_

I have two mapping types in my index (location and sequencefeature). I need  
to filter the query by sequencefeature mapping type and by a document  
field. The problem is: if I use the id field in the filter, the query  
returns zero results; but if I use another field (sequenceid), the query  
return 7 results as expected.

I you see, I'm passing an existing value for id field (102573058).

Em segunda-feira, 23 de dezembro de 2013 11h37min20s UTC-2, David Pilato  
escreveu:

> Is it your actual query?  
> Asking this because I can't see `type` field in your docs. Wondering how  
> 1st query could match?
> 
> Any chance that you create a full curl recreation and gist it?
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> 
> Le 23 décembre 2013 at 14:24:23, Bruno Galindro da Costa (  
> [bruno.g...@gmail.com](mailto:bruno.g...@gmail.com) \<javascript:\>) a écrit:
> 
> This query returns 7 itens:
> 
> curl -XGET "[http://localhost:9200/modmine/\_search](http://localhost:9200/modmine/_search)" -d'  
> {  
> "query": {  
> "filtered": {  
> "query": {  
> "match\_all": {}  
> },  
> "filter": {  
> "bool": {  
> "must": [  
> {  
> "type": {  
> "value": "sequencefeature"  
> }  
> }  
> ],  
> "must": [  
> {  
> "term": {  
> "sequenceid": "179781000"  
> }  
> }  
> ]  
> }  
> }  
> }  
> }  
> }'
> 
> Piece of result:
> 
> ```
> "hits": {
> "total": 7,
> "max_score": 1,
> "hits": [
> {
> "_index": "modmine",
> "_type": "sequencefeature",
> "_id": "111",
> "_score": 1,
> "_source": {
> "sequenceid": 179781000,
> "name": null,
> "symbol": null,
> "scoretype": 
> 
> ```
> 
> "RNAseq\_\_\_L4\_soma\_JK1107\_no\_DNaseI\_genelets\_revised\_100320:L4\_soma\_JK1107\_no\_DNaseI"  
> ,  
> "note": null,  
> "organismid": 11000000,  
> "length": 2,  
> "score": null,  
> "predictionstatus": null,  
> "chromosomelocationid": 102573059,  
> "chromosomeid": 11000003,  
> "secondaryidentifier":  
> "RNAseq\_\_\_L4\_soma\_JK1107\_no\_DNaseI\_genelets\_revised\_100320.exon\_I\_10074047\_10074048\_-_wb170"  
> ,  
> "cytolocation": null,  
> "scoreprotocolid": 76003281,  
> "class": "org.intermine.model.bio.Exon",  
> "id": 102573058,  
> "primaryidentifier":  
> "RNAseq\_\_\_L4\_soma\_JK1107\_no\_DNaseI\_genelets\_revised\_100320.exon\_I\_10074047\_10074048_-\_wb170"  
> ,  
> "sequenceontologytermid": 1000002  
> }  
> },
> 
> If I modify the query to search for _id_ field instead of _sequenceid_,  
> no results are displayed. Why?
> 
> curl -XGET "[http://localhost:9200/modmine/\_search](http://localhost:9200/modmine/_search)" -d'  
> {  
> "query": {  
> "filtered": {  
> "query": {  
> "match\_all": {}  
> },  
> "filter": {  
> "bool": {  
> "must": [  
> {  
> "type": {  
> "value": "sequencefeature"  
> }  
> }  
> ],  
> "must": [  
> {  
> "term": {  
> "id": "102573058"  
> }  
> }  
> ]  
> }  
> }  
> }  
> }  
> }'
> 
> {  
> "took": 2,  
> "timed\_out": false,  
> "\_shards": {  
> "total": 2,  
> "successful": 2,  
> "failed": 0  
> },  
> "hits": {  
> "total": 0,  
> "max\_score": null,  
> "hits":   
> }  
> }
> 
> --  
> 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/0f86ce39-f622-48bc-9d4f-54f07d8d0a59%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0f86ce39-f622-48bc-9d4f-54f07d8d0a59%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2e9c16ed-9388-46eb-be45-6169167b2841%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2e9c16ed-9388-46eb-be45-6169167b2841%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Bruno\_Galindro\_da\_Co](https://avatars.discourse-cdn.com/v4/letter/b/59ef9b/32.png) [@Bruno\_Galindro\_da\_Co](https://discuss.elastic.co/u/Bruno_Galindro_da_Co)
#### Post date: [December 23, 2013, 3:57pm UTC](https://discuss.elastic.co/t/bool-filter-is-not-searching-field-content/14998/4 "2013-12-23T15:57:36Z")

</div>

Hmmm. I think I know why, but I don't know how to make a workaround for  
this.

First I'll clarify the environment:

The data was imported from a genome database called modmine. Location and  
Sequencefeature are tables of it. So, I've built an index called modmine to  
represent the database and two mapping types (location and sequencefeature)  
to represent the tables:

Index name: modmine  
Mapping types: location and sequencefeature

As you can see bellow, the id field is present in both of the mapping  
types, as well as others (organismid, chromosomeid, ...). So, If I try to  
do a bool filter by type AND by one of those fields, the query displays  
zero results. If I use a "unique" field, the query returns the results as  
expected.

How can I solve my problem? I'll need to split data in two indexes instead  
of into two mapping types?

Here are the type mappings:

```
  "mappings": {
     "location": {
        "properties": {
           "id": {
              "type": "integer"
           },
           "featureid": {
              "type": "integer"
           },
           "strand": {
              "type": "multi_field",
              "fields": {
                 "strand": {
                    "index": "analyzed",
                    "type": "string"
                 },
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 }
              }
           },
           "organismid": {
              "type": "integer"
           },
           "intermine_start": {
              "type": "integer"
           },
           "class": {
              "type": "multi_field",
              "fields": {
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 },
                 "class": {
                    "index": "analyzed",
                    "type": "string"
                 }
              }
           },
           "intermine_end": {
              "type": "integer"
           },
           "locatedonid": {
              "type": "integer"
           },
           "chromosomeid": {
              "type": "integer"
           }
        }
     },
     "sequencefeature": {
        "properties": {
           "sequenceid": {
              "type": "integer"
           },
           "symbol": {
              "type": "multi_field",
              "fields": {
                 "symbol": {
                    "index": "analyzed",
                    "type": "string"
                 },
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 }
              }
           },
           "secondaryidentifier": {
              "type": "multi_field",
              "fields": {
                 "secondaryidentifier": {
                    "index": "analyzed",
                    "type": "string"
                 },
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 }
              }
           },
           "primaryidentifier": {
              "type": "multi_field",
              "fields": {
                 "primaryidentifier": {
                    "index": "analyzed",
                    "type": "string"
                 },
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 }
              }
           },
           "score": {
              "type": "double"
           },
           "class": {
              "type": "multi_field",
              "fields": {
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 },
                 "class": {
                    "index": "analyzed",
                    "type": "string"
                 }
              }
           },
           "scoreprotocolid": {
              "type": "integer"
           },
           "id": {
              "type": "integer"
           },
           "predictionstatus": {
              "type": "multi_field",
              "fields": {
                 "predictionstatus": {
                    "index": "analyzed",
                    "type": "string"
                 },
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 }
              }
           },
           "chromosomelocationid": {
              "type": "integer"
           },
           "sequenceontologytermid": {
              "type": "integer"
           },
           "organismid": {
              "type": "integer"
           },
           "name": {
              "type": "multi_field",
              "fields": {
                 "name": {
                    "index": "analyzed",
                    "type": "string"
                 },
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 }
              }
           },
           "length": {
              "type": "integer"
           },
           "cytolocation": {
              "type": "multi_field",
              "fields": {
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 },
                 "cytolocation": {
                    "index": "analyzed",
                    "type": "string"
                 }
              }
           },
           "chromosomeid": {
              "type": "integer"
           },
           "scoretype": {
              "type": "multi_field",
              "fields": {
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 },
                 "scoretype": {
                    "index": "analyzed",
                    "type": "string"
                 }
              }
           },
           "note": {
              "type": "multi_field",
              "fields": {
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 },
                 "note": {
                    "index": "analyzed",
                    "type": "string"
                 }
              }
           }
        }
     }
  }

```

}

Em segunda-feira, 23 de dezembro de 2013 13h38min30s UTC-2, Bruno Galindro  
da Costa escreveu:

> Is it your actual query?  
> Yes
> 
> Any chance that you create a full curl recreation and gist it?  
> Not understood sorry...
> 
> Asking this because I can't see `type` field in your docs. Wondering how  
> 1st query could match?  
> Yes, it does not have a "type" field.
> 
> What I need to do is a query filtering by the id field (not \_id) and the  
> mapping type must be _sequencefeature_
> 
> I have two mapping types in my index (location and sequencefeature). I  
> need to filter the query by sequencefeature mapping type and by a document  
> field. The problem is: if I use the id field in the filter, the query  
> returns zero results; but if I use another field (sequenceid), the query  
> return 7 results as expected.
> 
> I you see, I'm passing an existing value for id field (102573058).
> 
> Em segunda-feira, 23 de dezembro de 2013 11h37min20s UTC-2, David Pilato  
> escreveu:
> 
> > Is it your actual query?  
> > Asking this because I can't see `type` field in your docs. Wondering how  
> > 1st query could match?
> > 
> > Any chance that you create a full curl recreation and gist it?
> > 
> > --  
> > _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> > @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> > 
> > Le 23 décembre 2013 at 14:24:23, Bruno Galindro da Costa (  
> > [bruno.g...@gmail.com](mailto:bruno.g...@gmail.com)) a écrit:
> > 
> > This query returns 7 itens:
> > 
> > curl -XGET "[http://localhost:9200/modmine/\_search](http://localhost:9200/modmine/_search)" -d'  
> > {  
> > "query": {  
> > "filtered": {  
> > "query": {  
> > "match\_all": {}  
> > },  
> > "filter": {  
> > "bool": {  
> > "must": [  
> > {  
> > "type": {  
> > "value": "sequencefeature"  
> > }  
> > }  
> > ],  
> > "must": [  
> > {  
> > "term": {  
> > "sequenceid": "179781000"  
> > }  
> > }  
> > ]  
> > }  
> > }  
> > }  
> > }  
> > }'
> > 
> > Piece of result:
> > 
> > ```
> > "hits": {
> > "total": 7,
> > "max_score": 1,
> > "hits": [
> > {
> > "_index": "modmine",
> > "_type": "sequencefeature",
> > "_id": "111",
> > "_score": 1,
> > "_source": {
> > "sequenceid": 179781000,
> > "name": null,
> > "symbol": null,
> > "scoretype": 
> > 
> > ```
> > 
> > "RNAseq\_\_\_L4\_soma\_JK1107\_no\_DNaseI\_genelets\_revised\_100320:L4\_soma\_JK1107\_no\_DNaseI"  
> > ,  
> > "note": null,  
> > "organismid": 11000000,  
> > "length": 2,  
> > "score": null,  
> > "predictionstatus": null,  
> > "chromosomelocationid": 102573059,  
> > "chromosomeid": 11000003,  
> > "secondaryidentifier":  
> > "RNAseq\_\_\_L4\_soma\_JK1107\_no\_DNaseI\_genelets\_revised\_100320.exon\_I\_10074047\_10074048\_-_wb170"  
> > ,  
> > "cytolocation": null,  
> > "scoreprotocolid": 76003281,  
> > "class": "org.intermine.model.bio.Exon",  
> > "id": 102573058,  
> > "primaryidentifier":  
> > "RNAseq\_\_\_L4\_soma\_JK1107\_no\_DNaseI\_genelets\_revised\_100320.exon\_I\_10074047\_10074048_-\_wb170"  
> > ,  
> > "sequenceontologytermid": 1000002  
> > }  
> > },
> > 
> > If I modify the query to search for _id_ field instead of _sequenceid_,  
> > no results are displayed. Why?
> > 
> > curl -XGET "[http://localhost:9200/modmine/\_search](http://localhost:9200/modmine/_search)" -d'  
> > {  
> > "query": {  
> > "filtered": {  
> > "query": {  
> > "match\_all": {}  
> > },  
> > "filter": {  
> > "bool": {  
> > "must": [  
> > {  
> > "type": {  
> > "value": "sequencefeature"  
> > }  
> > }  
> > ],  
> > "must": [  
> > {  
> > "term": {  
> > "id": "102573058"  
> > }  
> > }  
> > ]  
> > }  
> > }  
> > }  
> > }  
> > }'
> > 
> > {  
> > "took": 2,  
> > "timed\_out": false,  
> > "\_shards": {  
> > "total": 2,  
> > "successful": 2,  
> > "failed": 0  
> > },  
> > "hits": {  
> > "total": 0,  
> > "max\_score": null,  
> > "hits":   
> > }  
> > }
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/0f86ce39-f622-48bc-9d4f-54f07d8d0a59%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0f86ce39-f622-48bc-9d4f-54f07d8d0a59%40googlegroups.com)  
> > .  
> > For more options, visit [https://groups.google.com/groups/opt\_out](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/43700739-bb0a-4fae-81de-73692f93a4d5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/43700739-bb0a-4fae-81de-73692f93a4d5%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [December 23, 2013, 4:03pm UTC](https://discuss.elastic.co/t/bool-filter-is-not-searching-field-content/14998/5 "2013-12-23T16:03:42Z")

</div>

Gist a curl recreation means what we wrote here: [http://www.elasticsearch.org/help/](http://www.elasticsearch.org/help/)  
It helps a lot to understand your concern and get the best answer as possible.

About your concern, may be you should consider to denormalize your two tables into a single document?

Hard to say more without some samples and your actual problem.

HTH

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 23 décembre 2013 at 16:57:40, Bruno Galindro da Costa ([bruno.galindro@gmail.com](mailto:bruno.galindro@gmail.com)) a écrit:

Hmmm. I think I know why, but I don't know how to make a workaround for this.

First I'll clarify the environment:

The data was imported from a genome database called modmine. Location and Sequencefeature are tables of it. So, I've built an index called modmine to represent the database and two mapping types (location and sequencefeature) to represent the tables:

Index name: modmine  
Mapping types: location and sequencefeature

As you can see bellow, the id field is present in both of the mapping types, as well as others (organismid, chromosomeid, ...). So, If I try to do a bool filter by type AND by one of those fields, the query displays zero results. If I use a "unique" field, the query returns the results as expected.

How can I solve my problem? I'll need to split data in two indexes instead of into two mapping types?

Here are the type mappings:

```
  "mappings": {
     "location": {
        "properties": {
           "id": {
              "type": "integer"
           },
           "featureid": {
              "type": "integer"
           },
           "strand": {
              "type": "multi_field",
              "fields": {
                 "strand": {
                    "index": "analyzed",
                    "type": "string"
                 },
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 }
              }
           },
           "organismid": {
              "type": "integer"
           },
           "intermine_start": {
              "type": "integer"
           },
           "class": {
              "type": "multi_field",
              "fields": {
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 },
                 "class": {
                    "index": "analyzed",
                    "type": "string"
                 }
              }
           },
           "intermine_end": {
              "type": "integer"
           },
           "locatedonid": {
              "type": "integer"
           },
           "chromosomeid": {
              "type": "integer"
           }
        }
     },
     "sequencefeature": {
        "properties": {
           "sequenceid": {
              "type": "integer"
           },
           "symbol": {
              "type": "multi_field",
              "fields": {
                 "symbol": {
                    "index": "analyzed",
                    "type": "string"
                 },
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 }
              }
           },
           "secondaryidentifier": {
              "type": "multi_field",
              "fields": {
                 "secondaryidentifier": {
                    "index": "analyzed",
                    "type": "string"
                 },
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 }
              }
           },
           "primaryidentifier": {
              "type": "multi_field",
              "fields": {
                 "primaryidentifier": {
                    "index": "analyzed",
                    "type": "string"
                 },
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 }
              }
           },
           "score": {
              "type": "double"
           },
           "class": {
              "type": "multi_field",
              "fields": {
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 },
                 "class": {
                    "index": "analyzed",
                    "type": "string"
                 }
              }
           },
           "scoreprotocolid": {
              "type": "integer"
           },
           "id": {
              "type": "integer"
           },
           "predictionstatus": {
              "type": "multi_field",
              "fields": {
                 "predictionstatus": {
                    "index": "analyzed",
                    "type": "string"
                 },
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 }
              }
           },
           "chromosomelocationid": {
              "type": "integer"
           },
           "sequenceontologytermid": {
              "type": "integer"
           },
           "organismid": {
              "type": "integer"
           },
           "name": {
              "type": "multi_field",
              "fields": {
                 "name": {
                    "index": "analyzed",
                    "type": "string"
                 },
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 }
              }
           },
           "length": {
              "type": "integer"
           },
           "cytolocation": {
              "type": "multi_field",
              "fields": {
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 },
                 "cytolocation": {
                    "index": "analyzed",
                    "type": "string"
                 }
              }
           },
           "chromosomeid": {
              "type": "integer"
           },
           "scoretype": {
              "type": "multi_field",
              "fields": {
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 },
                 "scoretype": {
                    "index": "analyzed",
                    "type": "string"
                 }
              }
           },
           "note": {
              "type": "multi_field",
              "fields": {
                 "original": {
                    "index": "not_analyzed",
                    "type": "string"
                 },
                 "note": {
                    "index": "analyzed",
                    "type": "string"
                 }
              }
           }
        }
     }
  }

```

}

Em segunda-feira, 23 de dezembro de 2013 13h38min30s UTC-2, Bruno Galindro da Costa escreveu:  
Is it your actual query?  
Yes

Any chance that you create a full curl recreation and gist it?  
Not understood sorry...

Asking this because I can't see `type` field in your docs. Wondering how 1st query could match?  
Yes, it does not have a "type" field.

What I need to do is a query filtering by the id field (not \_id) and the mapping type must be sequencefeature

I have two mapping types in my index (location and sequencefeature). I need to filter the query by sequencefeature mapping type and by a document field. The problem is: if I use the id field in the filter, the query returns zero results; but if I use another field (sequenceid), the query return 7 results as expected.

I you see, I'm passing an existing value for id field (102573058).

Em segunda-feira, 23 de dezembro de 2013 11h37min20s UTC-2, David Pilato escreveu:  
Is it your actual query?  
Asking this because I can't see `type` field in your docs. Wondering how 1st query could match?

Any chance that you create a full curl recreation and gist it?

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 23 décembre 2013 at 14:24:23, Bruno Galindro da Costa ([bruno.g...@gmail.com](mailto:bruno.g...@gmail.com)) a écrit:

This query returns 7 itens:

curl -XGET "[http://localhost:9200/modmine/\_search](http://localhost:9200/modmine/_search)" -d'  
{  
"query": {  
"filtered": {  
"query": {  
"match\_all": {}  
},  
"filter": {  
"bool": {  
"must": [  
{  
"type": {  
"value": "sequencefeature"  
}  
}  
],  
"must": [  
{  
"term": {  
"sequenceid": "179781000"  
}  
}  
]  
}  
}  
}  
}  
}'

Piece of result:

"hits": {  
"total": 7,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "modmine",  
"\_type": "sequencefeature",  
"\_id": "111",  
"\_score": 1,  
"_source": {  
"sequenceid": 179781000,  
"name": null,  
"symbol": null,  
"scoretype": "RNAseq\_\_\_L4\_soma\_JK1107\_no\_DNaseI\_genelets\_revised\_100320:L4\_soma\_JK1107\_no\_DNaseI",  
"note": null,  
"organismid": 11000000,  
"length": 2,  
"score": null,  
"predictionstatus": null,  
"chromosomelocationid": 102573059,  
"chromosomeid": 11000003,  
"secondaryidentifier": "RNAseq\_\_\_L4\_soma\_JK1107\_no\_DNaseI\_genelets\_revised\_100320.exon\_I\_10074047\_10074048_-_wb170",  
"cytolocation": null,  
"scoreprotocolid": 76003281,  
"class": "org.intermine.model.bio.Exon",  
"id": 102573058,  
"primaryidentifier": "RNAseq\_\_\_L4\_soma\_JK1107\_no\_DNaseI\_genelets\_revised\_100320.exon\_I\_10074047\_10074048_-\_wb170",  
"sequenceontologytermid": 1000002  
}  
},

If I modify the query to search for id field instead of sequenceid, no results are displayed. Why?

curl -XGET "[http://localhost:9200/modmine/\_search](http://localhost:9200/modmine/_search)" -d'  
{  
"query": {  
"filtered": {  
"query": {  
"match\_all": {}  
},  
"filter": {  
"bool": {  
"must": [  
{  
"type": {  
"value": "sequencefeature"  
}  
}  
],  
"must": [  
{  
"term": {  
"id": "102573058"  
}  
}  
]  
}  
}  
}  
}  
}'

{  
"took": 2,  
"timed\_out": false,  
"\_shards": {  
"total": 2,  
"successful": 2,  
"failed": 0  
},  
"hits": {  
"total": 0,  
"max\_score": null,  
"hits": []  
}  
}

## -- 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com). To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/0f86ce39-f622-48bc-9d4f-54f07d8d0a59%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0f86ce39-f622-48bc-9d4f-54f07d8d0a59%40googlegroups.com). For more options, visit [https://groups.google.com/groups/opt\_out](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/43700739-bb0a-4fae-81de-73692f93a4d5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/43700739-bb0a-4fae-81de-73692f93a4d5%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/etPan.52b85ede.168e121f.111%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.52b85ede.168e121f.111%40MacBook-Air-de-David.local).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Bruno\_Galindro\_da\_Co](https://avatars.discourse-cdn.com/v4/letter/b/59ef9b/32.png) [@Bruno\_Galindro\_da\_Co](https://discuss.elastic.co/u/Bruno_Galindro_da_Co)
#### Post date: [December 23, 2013, 4:41pm UTC](https://discuss.elastic.co/t/bool-filter-is-not-searching-field-content/14998/6 "2013-12-23T16:41:11Z")

</div>

About your concern, may be you should consider to denormalize your two  
tables into a single document?  
The fields have the same name in diferent tables, but they could have  
different values too. I know that I can change the field names and put a  
suffix in it to represent the tables, but I need to imput data into  
elasticsearch in the most similar way as it is in the relational database,  
to avoid confusion.

I'll make more tests here an return ASAP.

Em segunda-feira, 23 de dezembro de 2013 14h03min42s UTC-2, David Pilato  
escreveu:

> Gist a curl recreation means what we wrote here:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help/)  
> It helps a lot to understand your concern and get the best answer as  
> possible.
> 
> About your concern, may be you should consider to denormalize your two  
> tables into a single document?
> 
> Hard to say more without some samples and your actual problem.
> 
> HTH
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> 
> Le 23 décembre 2013 at 16:57:40, Bruno Galindro da Costa (  
> [bruno.g...@gmail.com](mailto:bruno.g...@gmail.com) \<javascript:\>) a écrit:
> 
> Hmmm. I think I know why, but I don't know how to make a workaround for  
> this.
> 
> First I'll clarify the environment:
> 
> The data was imported from a genome database called modmine. Location  
> and Sequencefeature are tables of it. So, I've built an index called  
> modmine to represent the database and two mapping types (location and sequencefeature)  
> to represent the tables:
> 
> Index name: modmine  
> Mapping types: location and sequencefeature
> 
> As you can see bellow, the id field is present in both of the mapping  
> types, as well as others (organismid, chromosomeid, ...). So, If I try to  
> do a bool filter by type AND by one of those fields, the query displays  
> zero results. If I use a "unique" field, the query returns the results as  
> expected.
> 
> How can I solve my problem? I'll need to split data in two indexes instead  
> of into two mapping types?
> 
> Here are the type mappings:
> 
> ```
> "mappings": {
> "location": {
> "properties": {
> "id": {
> "type": "integer"
> },
> "featureid": {
> "type": "integer"
> },
> "strand": {
> "type": "multi_field",
> "fields": {
> "strand": {
> "index": "analyzed",
> "type": "string"
> },
> "original": {
> "index": "not_analyzed",
> "type": "string"
> }
> }
> },
> "organismid": {
> "type": "integer"
> },
> "intermine_start": {
> "type": "integer"
> },
> "class": {
> "type": "multi_field",
> "fields": {
> "original": {
> "index": "not_analyzed",
> "type": "string"
> },
> "class": {
> "index": "analyzed",
> "type": "string"
> }
> }
> },
> "intermine_end": {
> "type": "integer"
> },
> "locatedonid": {
> "type": "integer"
> },
> "chromosomeid": {
> "type": "integer"
> }
> }
> },
> "sequencefeature": {
> "properties": {
> "sequenceid": {
> "type": "integer"
> },
> "symbol": {
> "type": "multi_field",
> "fields": {
> "symbol": {
> "index": "analyzed",
> "type": "string"
> },
> "original": {
> "index": "not_analyzed",
> "type": "string"
> }
> }
> },
> "secondaryidentifier": {
> "type": "multi_field",
> "fields": {
> "secondaryidentifier": {
> "index": "analyzed",
> "type": "string"
> },
> "original": {
> "index": "not_analyzed",
> "type": "string"
> }
> }
> },
> "primaryidentifier": {
> "type": "multi_field",
> "fields": {
> "primaryidentifier": {
> "index": "analyzed",
> "type": "string"
> },
> "original": {
> "index": "not_analyzed",
> "type": "string"
> }
> }
> },
> "score": {
> "type": "double"
> },
> "class": {
> "type": "multi_field",
> "fields": {
> "original": {
> "index": "not_analyzed",
> "type": "string"
> },
> "class": {
> "index": "analyzed",
> "type": "string"
> }
> }
> },
> "scoreprotocolid": {
> "type": "integer"
> },
> "id": {
> "type": "integer"
> },
> "predictionstatus": {
> "type": "multi_field",
> "fields": {
> "predictionstatus": {
> "index": "analyzed",
> "type": "string"
> },
> "original": {
> "index": "not_analyzed",
> "type": "string"
> }
> }
> },
> "chromosomelocationid": {
> "type": "integer"
> },
> "sequenceontologytermid": {
> "type": "integer"
> },
> "organismid": {
> "type": "integer"
> },
> "name": {
> "type": "multi_field",
> "fields": {
> "name": {
> "index": "analyzed",
> "type": "string"
> },
> "original": {
> "index": "not_analyzed",
> "type": "string"
> }
> }
> },
> "length": {
> "type": "integer"
> },
> "cytolocation": {
> "type": "multi_field",
> "fields": {
> "original": {
> "index": "not_analyzed",
> "type": "string"
> },
> "cytolocation": {
> "index": "analyzed",
> "type": "string"
> }
> }
> },
> "chromosomeid": {
> "type": "integer"
> },
> "scoretype": {
> "type": "multi_field",
> "fields": {
> "original": {
> "index": "not_analyzed",
> "type": "string"
> },
> "scoretype": {
> "index": "analyzed",
> "type": "string"
> }
> }
> },
> "note": {
> "type": "multi_field",
> "fields": {
> "original": {
> "index": "not_analyzed",
> "type": "string"
> },
> "note": {
> "index": "analyzed",
> "type": "string"
> }
> }
> }
> }
> }
> }
> 
> ```
> 
> }
> 
> Em segunda-feira, 23 de dezembro de 2013 13h38min30s UTC-2, Bruno Galindro  
> da Costa escreveu:
> 
> > Is it your actual query?  
> > Yes
> > 
> > Any chance that you create a full curl recreation and gist it?  
> > Not understood sorry...
> > 
> > Asking this because I can't see `type` field in your docs. Wondering how  
> > 1st query could match?  
> > Yes, it does not have a "type" field.
> > 
> > What I need to do is a query filtering by the id field (not \_id) and the  
> > mapping type must be _sequencefeature_
> > 
> > I have two mapping types in my index (location and sequencefeature). I  
> > need to filter the query by sequencefeature mapping type and by a document  
> > field. The problem is: if I use the id field in the filter, the query  
> > returns zero results; but if I use another field (sequenceid), the query  
> > return 7 results as expected.
> > 
> > I you see, I'm passing an existing value for id field (102573058).
> > 
> > Em segunda-feira, 23 de dezembro de 2013 11h37min20s UTC-2, David Pilato  
> > escreveu:
> > 
> > > Is it your actual query?  
> > > Asking this because I can't see `type` field in your docs. Wondering  
> > > how 1st query could match?
> > > 
> > > Any chance that you create a full curl recreation and gist it?
> > > 
> > > ```
> > > -- 
> > > 
> > > ```
> > > 
> > > _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> > > @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> > > 
> > > Le 23 décembre 2013 at 14:24:23, Bruno Galindro da Costa (  
> > > [bruno.g...@gmail.com](mailto:bruno.g...@gmail.com)) a écrit:
> > > 
> > > This query returns 7 itens:
> > > 
> > > curl -XGET "[http://localhost:9200/modmine/\_search](http://localhost:9200/modmine/_search)" -d'  
> > > {  
> > > "query": {  
> > > "filtered": {  
> > > "query": {  
> > > "match\_all": {}  
> > > },  
> > > "filter": {  
> > > "bool": {  
> > > "must": [  
> > > {  
> > > "type": {  
> > > "value": "sequencefeature"  
> > > }  
> > > }  
> > > ],  
> > > "must": [  
> > > {  
> > > "term": {  
> > > "sequenceid": "179781000"  
> > > }  
> > > }  
> > > ]  
> > > }  
> > > }  
> > > }  
> > > }  
> > > }'
> > > 
> > > Piece of result:
> > > 
> > > ```
> > > "hits": {
> > > "total": 7,
> > > "max_score": 1,
> > > "hits": [
> > > {
> > > "_index": "modmine",
> > > "_type": "sequencefeature",
> > > "_id": "111",
> > > "_score": 1,
> > > "_source": {
> > > "sequenceid": 179781000,
> > > "name": null,
> > > "symbol": null,
> > > "scoretype": 
> > > 
> > > ```
> > > 
> > > "RNAseq\_\_\_L4\_soma\_JK1107\_no\_DNaseI\_genelets\_revised\_100320:L4\_soma\_JK1107\_no\_DNaseI"  
> > > ,  
> > > "note": null,  
> > > "organismid": 11000000,  
> > > "length": 2,  
> > > "score": null,  
> > > "predictionstatus": null,  
> > > "chromosomelocationid": 102573059,  
> > > "chromosomeid": 11000003,  
> > > "secondaryidentifier":  
> > > "RNAseq\_\_\_L4\_soma\_JK1107\_no\_DNaseI\_genelets\_revised\_100320.exon\_I\_10074047\_10074048\_-_wb170"  
> > > ,  
> > > "cytolocation": null,  
> > > "scoreprotocolid": 76003281,  
> > > "class": "org.intermine.model.bio.Exon",  
> > > "id": 102573058,  
> > > "primaryidentifier":  
> > > "RNAseq\_\_\_L4\_soma\_JK1107\_no\_DNaseI\_genelets\_revised\_100320.exon\_I\_10074047\_10074048_-\_wb170"  
> > > ,  
> > > "sequenceontologytermid": 1000002  
> > > }  
> > > },
> > > 
> > > If I modify the query to search for _id_ field instead of _sequenceid_,  
> > > no results are displayed. Why?
> > > 
> > > curl -XGET "[http://localhost:9200/modmine/\_search](http://localhost:9200/modmine/_search)" -d'  
> > > {  
> > > "query": {  
> > > "filtered": {  
> > > "query": {  
> > > "match\_all": {}  
> > > },  
> > > "filter": {  
> > > "bool": {  
> > > "must": [  
> > > {  
> > > "type": {  
> > > "value": "sequencefeature"  
> > > }  
> > > }  
> > > ],  
> > > "must": [  
> > > {  
> > > "term": {  
> > > "id": "102573058"  
> > > }  
> > > }  
> > > ]  
> > > }  
> > > }  
> > > }  
> > > }  
> > > }'
> > > 
> > > {  
> > > "took": 2,  
> > > "timed\_out": false,  
> > > "\_shards": {  
> > > "total": 2,  
> > > "successful": 2,  
> > > "failed": 0  
> > > },  
> > > "hits": {  
> > > "total": 0,  
> > > "max\_score": null,  
> > > "hits":   
> > > }  
> > > }
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/0f86ce39-f622-48bc-9d4f-54f07d8d0a59%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0f86ce39-f622-48bc-9d4f-54f07d8d0a59%40googlegroups.com)  
> > > .  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/43700739-bb0a-4fae-81de-73692f93a4d5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/43700739-bb0a-4fae-81de-73692f93a4d5%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/00187a8e-20a7-4937-843e-e76d6606d4a7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/00187a8e-20a7-4937-843e-e76d6606d4a7%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Bruno\_Galindro\_da\_Co](https://avatars.discourse-cdn.com/v4/letter/b/59ef9b/32.png) [@Bruno\_Galindro\_da\_Co](https://discuss.elastic.co/u/Bruno_Galindro_da_Co)
#### Post date: [December 24, 2013, 1:07pm UTC](https://discuss.elastic.co/t/bool-filter-is-not-searching-field-content/14998/7 "2013-12-24T13:07:12Z")

</div>

After did some tests, I found the problem and a workaround for "solve" it.

To index documents, I was using the Official Python low-level client for  
Elasticsearch [https://github.com/elasticsearch/elasticsearch-py](https://github.com/elasticsearch/elasticsearch-py). For some  
reason, after index some documents in location type, if I index documents  
in other type (sequencefeature in my case) the reported problem occurs.  
I've did a curl recriation to validate this and from curl command line,  
everything works great.

Another strange behaviour is that the above client was duplicating the  
first document indexed. Maybe this is because the index method call is  
inside a loop. So, I've decided to put statical data in the index method  
call outside the loop. But the same behaviour occured.

So, I've decided to use another client -\>  
pyes[http://pyes.readthedocs.org/en/latest/](http://pyes.readthedocs.org/en/latest/).  
Now everything is working properly.

This is my final script:  
[https://gist.github.com/galindro/8113011#file-pg\_to\_es-py](https://gist.github.com/galindro/8113011#file-pg_to_es-py)

2013/12/23 Bruno Galindro da Costa [bruno.galindro@gmail.com](mailto:bruno.galindro@gmail.com)

> About your concern, may be you should consider to denormalize your two  
> tables into a single document?  
> The fields have the same name in diferent tables, but they could have  
> different values too. I know that I can change the field names and put a  
> suffix in it to represent the tables, but I need to imput data into  
> elasticsearch in the most similar way as it is in the relational database,  
> to avoid confusion.
> 
> I'll make more tests here an return ASAP.
> 
> Em segunda-feira, 23 de dezembro de 2013 14h03min42s UTC-2, David Pilato  
> escreveu:
> 
> > Gist a curl recreation means what we wrote here: [http://www](http://www).  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://elasticsearch.org/help/)  
> > It helps a lot to understand your concern and get the best answer as  
> > possible.
> > 
> > About your concern, may be you should consider to denormalize your two  
> > tables into a single document?
> > 
> > Hard to say more without some samples and your actual problem.
> > 
> > HTH
> > 
> > --  
> > _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> > @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> > 
> > Le 23 décembre 2013 at 16:57:40, Bruno Galindro da Costa (  
> > [bruno.g...@gmail.com](mailto:bruno.g...@gmail.com)) a écrit:
> > 
> > Hmmm. I think I know why, but I don't know how to make a workaround for  
> > this.
> > 
> > First I'll clarify the environment:
> > 
> > The data was imported from a genome database called modmine. Location  
> > and Sequencefeature are tables of it. So, I've built an index called  
> > modmine to represent the database and two mapping types (location and sequencefeature)  
> > to represent the tables:
> > 
> > Index name: modmine  
> > Mapping types: location and sequencefeature
> > 
> > As you can see bellow, the id field is present in both of the mapping  
> > types, as well as others (organismid, chromosomeid, ...). So, If I try to  
> > do a bool filter by type AND by one of those fields, the query displays  
> > zero results. If I use a "unique" field, the query returns the results as  
> > expected.
> > 
> > How can I solve my problem? I'll need to split data in two indexes  
> > instead of into two mapping types?
> > 
> > Here are the type mappings:
> > 
> > ```
> > "mappings": {
> > "location": {
> > "properties": {
> > "id": {
> > "type": "integer"
> > },
> > "featureid": {
> > "type": "integer"
> > },
> > "strand": {
> > "type": "multi_field",
> > "fields": {
> > "strand": {
> > "index": "analyzed",
> > "type": "string"
> > },
> > "original": {
> > "index": "not_analyzed",
> > "type": "string"
> > }
> > }
> > },
> > "organismid": {
> > "type": "integer"
> > },
> > "intermine_start": {
> > "type": "integer"
> > },
> > "class": {
> > "type": "multi_field",
> > "fields": {
> > "original": {
> > "index": "not_analyzed",
> > "type": "string"
> > },
> > "class": {
> > "index": "analyzed",
> > "type": "string"
> > }
> > }
> > },
> > "intermine_end": {
> > "type": "integer"
> > },
> > "locatedonid": {
> > "type": "integer"
> > },
> > "chromosomeid": {
> > "type": "integer"
> > }
> > }
> > },
> > "sequencefeature": {
> > "properties": {
> > "sequenceid": {
> > "type": "integer"
> > },
> > "symbol": {
> > "type": "multi_field",
> > "fields": {
> > "symbol": {
> > "index": "analyzed",
> > "type": "string"
> > },
> > "original": {
> > "index": "not_analyzed",
> > "type": "string"
> > }
> > }
> > },
> > "secondaryidentifier": {
> > "type": "multi_field",
> > "fields": {
> > "secondaryidentifier": {
> > "index": "analyzed",
> > "type": "string"
> > },
> > "original": {
> > "index": "not_analyzed",
> > "type": "string"
> > }
> > }
> > },
> > "primaryidentifier": {
> > "type": "multi_field",
> > "fields": {
> > "primaryidentifier": {
> > "index": "analyzed",
> > "type": "string"
> > },
> > "original": {
> > "index": "not_analyzed",
> > "type": "string"
> > }
> > }
> > },
> > "score": {
> > "type": "double"
> > },
> > "class": {
> > "type": "multi_field",
> > "fields": {
> > "original": {
> > "index": "not_analyzed",
> > "type": "string"
> > },
> > "class": {
> > "index": "analyzed",
> > "type": "string"
> > }
> > }
> > },
> > "scoreprotocolid": {
> > "type": "integer"
> > },
> > "id": {
> > "type": "integer"
> > },
> > "predictionstatus": {
> > "type": "multi_field",
> > "fields": {
> > "predictionstatus": {
> > "index": "analyzed",
> > "type": "string"
> > },
> > "original": {
> > "index": "not_analyzed",
> > "type": "string"
> > }
> > }
> > },
> > "chromosomelocationid": {
> > "type": "integer"
> > },
> > "sequenceontologytermid": {
> > "type": "integer"
> > },
> > "organismid": {
> > "type": "integer"
> > },
> > "name": {
> > "type": "multi_field",
> > "fields": {
> > "name": {
> > "index": "analyzed",
> > "type": "string"
> > },
> > "original": {
> > "index": "not_analyzed",
> > "type": "string"
> > }
> > }
> > },
> > "length": {
> > "type": "integer"
> > },
> > "cytolocation": {
> > "type": "multi_field",
> > "fields": {
> > "original": {
> > "index": "not_analyzed",
> > "type": "string"
> > },
> > "cytolocation": {
> > "index": "analyzed",
> > "type": "string"
> > }
> > }
> > },
> > "chromosomeid": {
> > "type": "integer"
> > },
> > "scoretype": {
> > "type": "multi_field",
> > "fields": {
> > "original": {
> > "index": "not_analyzed",
> > "type": "string"
> > },
> > "scoretype": {
> > "index": "analyzed",
> > "type": "string"
> > }
> > }
> > },
> > "note": {
> > "type": "multi_field",
> > "fields": {
> > "original": {
> > "index": "not_analyzed",
> > "type": "string"
> > },
> > "note": {
> > "index": "analyzed",
> > "type": "string"
> > }
> > }
> > }
> > }
> > }
> > }
> > 
> > ```
> > 
> > }
> > 
> > Em segunda-feira, 23 de dezembro de 2013 13h38min30s UTC-2, Bruno  
> > Galindro da Costa escreveu:
> > 
> > > Is it your actual query?  
> > > Yes
> > > 
> > > Any chance that you create a full curl recreation and gist it?  
> > > Not understood sorry...
> > > 
> > > Asking this because I can't see `type` field in your docs. Wondering how  
> > > 1st query could match?  
> > > Yes, it does not have a "type" field.
> > > 
> > > What I need to do is a query filtering by the id field (not \_id) and the  
> > > mapping type must be _sequencefeature_
> > > 
> > > I have two mapping types in my index (location and sequencefeature). I  
> > > need to filter the query by sequencefeature mapping type and by a document  
> > > field. The problem is: if I use the id field in the filter, the query  
> > > returns zero results; but if I use another field (sequenceid), the  
> > > query return 7 results as expected.
> > > 
> > > I you see, I'm passing an existing value for id field (102573058).
> > > 
> > > Em segunda-feira, 23 de dezembro de 2013 11h37min20s UTC-2, David Pilato  
> > > escreveu:
> > > 
> > > > Is it your actual query?  
> > > > Asking this because I can't see `type` field in your docs. Wondering  
> > > > how 1st query could match?
> > > > 
> > > > Any chance that you create a full curl recreation and gist it?
> > > > 
> > > > ```
> > > > --
> > > > 
> > > > ```
> > > > 
> > > > _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> > > > @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> > > > 
> > > > Le 23 décembre 2013 at 14:24:23, Bruno Galindro da Costa (  
> > > > [bruno.g...@gmail.com](mailto:bruno.g...@gmail.com)) a écrit:
> > > > 
> > > > This query returns 7 itens:
> > > > 
> > > > curl -XGET "[http://localhost:9200/modmine/\_search](http://localhost:9200/modmine/_search)" -d'  
> > > > {  
> > > > "query": {  
> > > > "filtered": {  
> > > > "query": {  
> > > > "match\_all": {}  
> > > > },  
> > > > "filter": {  
> > > > "bool": {  
> > > > "must": [  
> > > > {  
> > > > "type": {  
> > > > "value": "sequencefeature"  
> > > > }  
> > > > }  
> > > > ],  
> > > > "must": [  
> > > > {  
> > > > "term": {  
> > > > "sequenceid": "179781000"  
> > > > }  
> > > > }  
> > > > ]  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > }'
> > > > 
> > > > Piece of result:
> > > > 
> > > > ```
> > > > "hits": {
> > > > "total": 7,
> > > > "max_score": 1,
> > > > "hits": [
> > > > {
> > > > "_index": "modmine",
> > > > "_type": "sequencefeature",
> > > > "_id": "111",
> > > > "_score": 1,
> > > > "_source": {
> > > > "sequenceid": 179781000,
> > > > "name": null,
> > > > "symbol": null,
> > > > "scoretype": "RNAseq___L4_soma_JK1107_no_
> > > > 
> > > > ```
> > > > 
> > > > DNaseI\_genelets\_revised\_100320:L4\_soma\_JK1107\_no\_DNaseI",  
> > > > "note": null,  
> > > > "organismid": 11000000,  
> > > > "length": 2,  
> > > > "score": null,  
> > > > "predictionstatus": null,  
> > > > "chromosomelocationid": 102573059,  
> > > > "chromosomeid": 11000003,  
> > > > "secondaryidentifier": "RNAseq\_\_\_L4\_soma\_JK1107\_no\_  
> > > > DNaseI\_genelets\_revised\_100320.exon\_I\_10074047\_10074048\_-_wb170",  
> > > > "cytolocation": null,  
> > > > "scoreprotocolid": 76003281,  
> > > > "class": "org.intermine.model.bio.Exon",  
> > > > "id": 102573058,  
> > > > "primaryidentifier": "RNAseq\_\_\_L4\_soma\_JK1107\_no_  
> > > > DNaseI\_genelets\_revised\_100320.exon\_I\_10074047\_10074048\_-\_wb170",  
> > > > "sequenceontologytermid": 1000002  
> > > > }  
> > > > },
> > > > 
> > > > If I modify the query to search for _id_ field instead of _sequenceid_,  
> > > > no results are displayed. Why?
> > > > 
> > > > curl -XGET "[http://localhost:9200/modmine/\_search](http://localhost:9200/modmine/_search)" -d'  
> > > > {  
> > > > "query": {  
> > > > "filtered": {  
> > > > "query": {  
> > > > "match\_all": {}  
> > > > },  
> > > > "filter": {  
> > > > "bool": {  
> > > > "must": [  
> > > > {  
> > > > "type": {  
> > > > "value": "sequencefeature"  
> > > > }  
> > > > }  
> > > > ],  
> > > > "must": [  
> > > > {  
> > > > "term": {  
> > > > "id": "102573058"  
> > > > }  
> > > > }  
> > > > ]  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > }'
> > > > 
> > > > {  
> > > > "took": 2,  
> > > > "timed\_out": false,  
> > > > "\_shards": {  
> > > > "total": 2,  
> > > > "successful": 2,  
> > > > "failed": 0  
> > > > },  
> > > > "hits": {  
> > > > "total": 0,  
> > > > "max\_score": null,  
> > > > "hits":   
> > > > }  
> > > > }
> > > > 
> > > > --  
> > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/0f86ce39-f622-48bc-9d4f-54f07d8d0a59%  
> > > > [40googlegroups.com](http://40googlegroups.com).  
> > > > For more options, visit [https://groups.google.com/groups/opt\_out](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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > msgid/elasticsearch/43700739-bb0a-4fae-81de-73692f93a4d5%  
> > [40googlegroups.com](http://40googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](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/6vrDqTJ9GGY/unsubscribe](https://groups.google.com/d/topic/elasticsearch/6vrDqTJ9GGY/unsubscribe).  
> > To unsubscribe from this group and all its topics, 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/00187a8e-20a7-4937-843e-e76d6606d4a7%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/00187a8e-20a7-4937-843e-e76d6606d4a7%40googlegroups.com)  
> > .
> 
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Att.  
Bruno Galindro da Costa

--  
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/CAE%3DUkuqsG5x1U82i\_SVebrzKfoWo4Us%2BKqBTUPquQb89ECCNxw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAE%3DUkuqsG5x1U82i_SVebrzKfoWo4Us%2BKqBTUPquQb89ECCNxw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:59am UTC](https://discuss.elastic.co/t/bool-filter-is-not-searching-field-content/14998/8 "2017-07-06T01:59:30Z")

</div>


