# One index has different \_type and different \_type have same field with different type will disturb？

**URL:** <https://discuss.elastic.co/t/one-index-has-different--type-and-different--type-have-same-field-with-different-type-will-disturb/18817>\
**Category:** Elasticsearch\
**Created:** [July 23, 2014, 9:53am UTC](https://discuss.elastic.co/t/one-index-has-different--type-and-different--type-have-same-field-with-different-type-will-disturb/18817 "2014-07-23T09:53:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xu\_piao](https://avatars.discourse-cdn.com/v4/letter/x/f14d63/32.png) [@xu\_piao](https://discuss.elastic.co/u/xu_piao)\
**Post date:** [July 23, 2014, 9:53am UTC](https://discuss.elastic.co/t/one-index-has-different--type-and-different--type-have-same-field-with-different-type-will-disturb/18817/1 "2014-07-23T09:53:37Z")

</div>

i have one index with different \_type like [http://localhost:9200/matrix/group](http://localhost:9200/matrix/group)  
and [http://localhost:9200/matrix/user](http://localhost:9200/matrix/user)

the two \_type all have 'region' field but with different type.  
group :

- region: {
  - type: string
  - store: true
  - analyzer: ik  
}

}

user:

- region: {
  - type: "long"  
}

when 'matrix' index only have 'group' type.  
i do search use 'query\_string' with multi\_field is ok

{  
"bool" : {  
"must" : {  
"query\_string" : {  
"query" : "北京西城",  
"fields" : [ "name^20", "tags^5", "intra^1", "region^2",  
"address^2" ]  
}  
},  
"minimum\_should\_match" : "1"  
}  
}

but when i index 'user' type .do zhe same query it will throw exception

org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to  
execute phase [query], all shards failed; shardFailures  
{[\_vgvj\_11QpKOuZNo90nD\_A][matrix][0]: RemoteTransportException[[Blizzard  
II][inet[/10.0.8.235:19300]][search/phase/query]]; nested:  
QueryPhaseExecutionException[[matrix][0]: query[filtered((region:"北京  
西路"))-\>cache(\_type:group)],from[0],size[20]: Query Failed [Failed to  
execute main query]]; nested: IllegalStateException[field "region" was  
indexed without position data; cannot run PhraseQuery (term=北京)];  
}{[\_vgvj\_11QpKOuZNo90nD\_A][matrix][4]: RemoteTransportException[[Blizzard  
II][inet[/10.0.8.235:19300]][search/phase/query]]; nested:  
QueryPhaseExecutionException[[matrix][4]: query[filtered((region:"北京  
西路"))-\>cache(\_type:group)],from[0],size[20]: Query Failed [Failed to  
execute main query]]; nested: IllegalStateException[field "region" was  
indexed without position data; cannot run PhraseQuery (term=北京)];  
}{[\_vgvj\_11QpKOuZNo90nD\_A][matrix][3]: RemoteTransportException[[Blizzard  
II][inet[/10.0.8.235:19300]][search/phase/query]]; nested:  
QueryPhaseExecutionException[[matrix][3]: query[filtered((region:"北京  
西路"))-\>cache(\_type:group)],from[0],size[20]: Query Failed [Failed to  
execute main query]]; nested: IllegalStateException[field "region" was  
indexed without position data; cannot run PhraseQuery (term=北京)];  
}{[3XK6HZ\_WSbG4E7Tot3mMMw][matrix][2]:  
QueryPhaseExecutionException[[matrix][2]: query[filtered((region:"北京  
西路"))-\>cache(\_type:group)],from[0],size[20]: Query Failed [Failed to  
execute main query]]; nested: IllegalStateException[field "region" was  
indexed without position data; cannot run PhraseQuery (term=北京)];  
}{[3XK6HZ\_WSbG4E7Tot3mMMw][matrix][1]:  
QueryPhaseExecutionException[[matrix][1]: query[filtered((region:"北京  
西路"))-\>cache(\_type:group)],from[0],size[20]: Query Failed [Failed to  
execute main query]]; nested: IllegalStateException[field "region" was  
indexed without position data; cannot run PhraseQuery (term=北京)]; }  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.onFirstPhaseResult(TransportSearchTypeAction.java:276)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$3.onFailure(TransportSearchTypeAction.java:224)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:205)  
at  
org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:216)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$4.run(TransportSearchTypeAction.java:296)  
at  
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)  
at java.lang.Thread.run(Thread.java:722)

all my search request has assign type in java like :

SearchRequestBuilder searchRequest =  
esClient.prepareSearch("matrix").setTypes("group")

.setSearchType(SearchType.QUERY\_THEN\_FETCH).setFrom(form).setSize(count).setExplain(true);

why ??

--  
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/850a4e92-1b7c-4564-9769-16bcdb9d4333%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/850a4e92-1b7c-4564-9769-16bcdb9d4333%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [July 23, 2014, 5:41pm UTC](https://discuss.elastic.co/t/one-index-has-different--type-and-different--type-have-same-field-with-different-type-will-disturb/18817/2 "2014-07-23T17:41:12Z")

</div>

In the end, all the documents end up in the same Lucene index, and while  
Lucene is schema-less, all similarly named fields must be the same type.  
Types are useful in Elasticsearch to separate different type  
configurations, but will fail on similarly named fields.

There is some work being done to remove the ambiguity, but for now it is  
best to avoid reusing field names across types in the same index.

I am assuming this issue is what is causing the problems in your other  
thread.

Cheers,

Ivan

On Wed, Jul 23, 2014 at 2:53 AM, xu piao [xupiaobj@gmail.com](mailto:xupiaobj@gmail.com) wrote:

> i have one index with different \_type like  
> [http://localhost:9200/matrix/group](http://localhost:9200/matrix/group) and [http://localhost:9200/matrix/user](http://localhost:9200/matrix/user)
> 
> the two \_type all have 'region' field but with different type.  
> group :
> 
> - region: {
> - type: string
> - store: true
> - analyzer: ik  
> }
> 
> }
> 
> user:
> 
> - region: {
> - type: "long"  
> }
> 
> when 'matrix' index only have 'group' type.  
> i do search use 'query\_string' with multi\_field is ok
> 
> {  
> "bool" : {  
> "must" : {  
> "query\_string" : {  
> "query" : "北京西城",  
> "fields" : [ "name^20", "tags^5", "intra^1", "region^2",  
> "address^2" ]  
> }  
> },  
> "minimum\_should\_match" : "1"  
> }  
> }
> 
> but when i index 'user' type .do zhe same query it will throw exception
> 
> org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to  
> execute phase [query], all shards failed; shardFailures  
> {[\_vgvj\_11QpKOuZNo90nD\_A][matrix][0]: RemoteTransportException[[Blizzard  
> II][inet[/10.0.8.235:19300]][search/phase/query]]; nested:  
> QueryPhaseExecutionException[[matrix][0]: query[filtered((region:"北京  
> 西路"))-\>cache(\_type:group)],from[0],size[20]: Query Failed [Failed to  
> execute main query]]; nested: IllegalStateException[field "region" was  
> indexed without position data; cannot run PhraseQuery (term=北京)];  
> }{[\_vgvj\_11QpKOuZNo90nD\_A][matrix][4]: RemoteTransportException[[Blizzard  
> II][inet[/10.0.8.235:19300]][search/phase/query]]; nested:  
> QueryPhaseExecutionException[[matrix][4]: query[filtered((region:"北京  
> 西路"))-\>cache(\_type:group)],from[0],size[20]: Query Failed [Failed to  
> execute main query]]; nested: IllegalStateException[field "region" was  
> indexed without position data; cannot run PhraseQuery (term=北京)];  
> }{[\_vgvj\_11QpKOuZNo90nD\_A][matrix][3]: RemoteTransportException[[Blizzard  
> II][inet[/10.0.8.235:19300]][search/phase/query]]; nested:  
> QueryPhaseExecutionException[[matrix][3]: query[filtered((region:"北京  
> 西路"))-\>cache(\_type:group)],from[0],size[20]: Query Failed [Failed to  
> execute main query]]; nested: IllegalStateException[field "region" was  
> indexed without position data; cannot run PhraseQuery (term=北京)];  
> }{[3XK6HZ\_WSbG4E7Tot3mMMw][matrix][2]:  
> QueryPhaseExecutionException[[matrix][2]: query[filtered((region:"北京  
> 西路"))-\>cache(\_type:group)],from[0],size[20]: Query Failed [Failed to  
> execute main query]]; nested: IllegalStateException[field "region" was  
> indexed without position data; cannot run PhraseQuery (term=北京)];  
> }{[3XK6HZ\_WSbG4E7Tot3mMMw][matrix][1]:  
> QueryPhaseExecutionException[[matrix][1]: query[filtered((region:"北京  
> 西路"))-\>cache(\_type:group)],from[0],size[20]: Query Failed [Failed to  
> execute main query]]; nested: IllegalStateException[field "region" was  
> indexed without position data; cannot run PhraseQuery (term=北京)]; }  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.onFirstPhaseResult(TransportSearchTypeAction.java:276)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$3.onFailure(TransportSearchTypeAction.java:224)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:205)  
> at  
> org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:216)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$4.run(TransportSearchTypeAction.java:296)  
> at  
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)  
> at java.lang.Thread.run(Thread.java:722)
> 
> all my search request has assign type in java like :
> 
> SearchRequestBuilder searchRequest =  
> esClient.prepareSearch("matrix").setTypes("group")
> 
> .setSearchType(SearchType.QUERY\_THEN\_FETCH).setFrom(form).setSize(count).setExplain(true);
> 
> why ??
> 
> --  
> 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/850a4e92-1b7c-4564-9769-16bcdb9d4333%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/850a4e92-1b7c-4564-9769-16bcdb9d4333%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/850a4e92-1b7c-4564-9769-16bcdb9d4333%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/850a4e92-1b7c-4564-9769-16bcdb9d4333%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CALY%3DcQAPp2gPhRCbvcVMfR12M5J\_8Q%2BSD%2BBMMFVpJ3DPjEAbwQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQAPp2gPhRCbvcVMfR12M5J_8Q%2BSD%2BBMMFVpJ3DPjEAbwQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![xu\_piao](https://avatars.discourse-cdn.com/v4/letter/x/f14d63/32.png) [@xu\_piao](https://discuss.elastic.co/u/xu_piao)\
**Post date:** [July 23, 2014, 5:49pm UTC](https://discuss.elastic.co/t/one-index-has-different--type-and-different--type-have-same-field-with-different-type-will-disturb/18817/3 "2014-07-23T17:49:44Z")

</div>

my es log is :

org.elasticsearch.transport.RemoteTransportException: [Yuriko  
Oyama][inet[/10.0.8.102:19300]][search/phase/query]  
Caused by: org.elasticsearch.search.query.QueryPhaseExecutionException:  
[matrix][1]: query[filtered(name:"北京 西路"^20.0 tags:"北京 西路"^5.0 intra:"北京  
西路" region:"北京 西路"^2.0 address:"北京  
西路"^2.0)-\>cache(\_type:group)],from[0],size[20],sort[\<custom:"geo":  
org.elasticsearch.index.fielddata.fieldcomparator.GeoDistanceComparatorSource@5a2bfbb5\>]:  
Query Failed [Failed to execute main query]  
at  
org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:127)  
at  
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:257)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryTransportHandler.messageReceived(SearchServiceTransportAction.java:623)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryTransportHandler.messageReceived(SearchServiceTransportAction.java:612)  
at  
org.elasticsearch.transport.netty.MessageChannelHandler$RequestHandler.run(MessageChannelHandler.java:270)  
at  
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)  
at java.lang.Thread.run(Thread.java:722)  
Caused by: java.lang.IllegalStateException: field "region" was indexed  
without position data; cannot run PhraseQuery (term=北京)  
at  
org.apache.lucene.search.PhraseQuery$PhraseWeight.scorer(PhraseQuery.java:278)  
at  
org.apache.lucene.search.BooleanQuery$BooleanWeight.scorer(BooleanQuery.java:317)  
at  
org.apache.lucene.search.FilteredQuery$RandomAccessFilterStrategy.filteredScorer(FilteredQuery.java:526)  
at  
org.apache.lucene.search.FilteredQuery$1.scorer(FilteredQuery.java:136)  
at  
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:618)  
at  
org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:173)  
at  
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:581)  
at  
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:533)  
at  
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:510)  
at  
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:345)  
at  
org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:116)

I have another question : one index is like a database or table ?

在 2014年7月24日星期四UTC+8上午1时41分23秒，Ivan Brusic写道：

> In the end, all the documents end up in the same Lucene index, and while  
> Lucene is schema-less, all similarly named fields must be the same type.  
> Types are useful in Elasticsearch to separate different type  
> configurations, but will fail on similarly named fields.
> 
> There is some work being done to remove the ambiguity, but for now it is  
> best to avoid reusing field names across types in the same index.
> 
> I am assuming this issue is what is causing the problems in your other  
> thread.
> 
> Cheers,
> 
> Ivan
> 
> On Wed, Jul 23, 2014 at 2:53 AM, xu piao \<[xupi...@gmail.com](mailto:xupi...@gmail.com) \<javascript:\>\>  
> wrote:
> 
> > i have one index with different \_type like  
> > [http://localhost:9200/matrix/group](http://localhost:9200/matrix/group) and [http://localhost:9200/matrix/user](http://localhost:9200/matrix/user)
> > 
> > the two \_type all have 'region' field but with different type.  
> > group :
> > 
> > - region: {
> > - type: string
> > - store: true
> > - analyzer: ik  
> > }
> > 
> > }
> > 
> > user:
> > 
> > - region: {
> > - type: "long"  
> > }
> > 
> > when 'matrix' index only have 'group' type.  
> > i do search use 'query\_string' with multi\_field is ok
> > 
> > {  
> > "bool" : {  
> > "must" : {  
> > "query\_string" : {  
> > "query" : "北京西城",  
> > "fields" : [ "name^20", "tags^5", "intra^1", "region^2",  
> > "address^2" ]  
> > }  
> > },  
> > "minimum\_should\_match" : "1"  
> > }  
> > }
> > 
> > but when i index 'user' type .do zhe same query it will throw exception
> > 
> > org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to  
> > execute phase [query], all shards failed; shardFailures  
> > {[\_vgvj\_11QpKOuZNo90nD\_A][matrix][0]: RemoteTransportException[[Blizzard  
> > II][inet[/10.0.8.235:19300]][search/phase/query]]; nested:  
> > QueryPhaseExecutionException[[matrix][0]: query[filtered((region:"北京  
> > 西路"))-\>cache(\_type:group)],from[0],size[20]: Query Failed [Failed to  
> > execute main query]]; nested: IllegalStateException[field "region" was  
> > indexed without position data; cannot run PhraseQuery (term=北京)];  
> > }{[\_vgvj\_11QpKOuZNo90nD\_A][matrix][4]: RemoteTransportException[[Blizzard  
> > II][inet[/10.0.8.235:19300]][search/phase/query]]; nested:  
> > QueryPhaseExecutionException[[matrix][4]: query[filtered((region:"北京  
> > 西路"))-\>cache(\_type:group)],from[0],size[20]: Query Failed [Failed to  
> > execute main query]]; nested: IllegalStateException[field "region" was  
> > indexed without position data; cannot run PhraseQuery (term=北京)];  
> > }{[\_vgvj\_11QpKOuZNo90nD\_A][matrix][3]: RemoteTransportException[[Blizzard  
> > II][inet[/10.0.8.235:19300]][search/phase/query]]; nested:  
> > QueryPhaseExecutionException[[matrix][3]: query[filtered((region:"北京  
> > 西路"))-\>cache(\_type:group)],from[0],size[20]: Query Failed [Failed to  
> > execute main query]]; nested: IllegalStateException[field "region" was  
> > indexed without position data; cannot run PhraseQuery (term=北京)];  
> > }{[3XK6HZ\_WSbG4E7Tot3mMMw][matrix][2]:  
> > QueryPhaseExecutionException[[matrix][2]: query[filtered((region:"北京  
> > 西路"))-\>cache(\_type:group)],from[0],size[20]: Query Failed [Failed to  
> > execute main query]]; nested: IllegalStateException[field "region" was  
> > indexed without position data; cannot run PhraseQuery (term=北京)];  
> > }{[3XK6HZ\_WSbG4E7Tot3mMMw][matrix][1]:  
> > QueryPhaseExecutionException[[matrix][1]: query[filtered((region:"北京  
> > 西路"))-\>cache(\_type:group)],from[0],size[20]: Query Failed [Failed to  
> > execute main query]]; nested: IllegalStateException[field "region" was  
> > indexed without position data; cannot run PhraseQuery (term=北京)]; }  
> > at  
> > org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.onFirstPhaseResult(TransportSearchTypeAction.java:276)  
> > at  
> > org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$3.onFailure(TransportSearchTypeAction.java:224)  
> > at  
> > org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:205)  
> > at  
> > org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)  
> > at  
> > org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:216)  
> > at  
> > org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$4.run(TransportSearchTypeAction.java:296)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)  
> > at  
> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)  
> > at java.lang.Thread.run(Thread.java:722)
> > 
> > all my search request has assign type in java like :
> > 
> > SearchRequestBuilder searchRequest =  
> > esClient.prepareSearch("matrix").setTypes("group")
> > 
> > .setSearchType(SearchType.QUERY\_THEN\_FETCH).setFrom(form).setSize(count).setExplain(true);
> > 
> > why ??
> > 
> > --  
> > 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/850a4e92-1b7c-4564-9769-16bcdb9d4333%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/850a4e92-1b7c-4564-9769-16bcdb9d4333%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/850a4e92-1b7c-4564-9769-16bcdb9d4333%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/850a4e92-1b7c-4564-9769-16bcdb9d4333%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/1ae65ce3-8c04-461b-81ee-86075b7558bf%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1ae65ce3-8c04-461b-81ee-86075b7558bf%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![xu\_piao](https://avatars.discourse-cdn.com/v4/letter/x/f14d63/32.png) [@xu\_piao](https://discuss.elastic.co/u/xu_piao)\
**Post date:** [July 24, 2014, 2:23am UTC](https://discuss.elastic.co/t/one-index-has-different--type-and-different--type-have-same-field-with-different-type-will-disturb/18817/4 "2014-07-24T02:23:37Z")

</div>

in order to save this problem, i have try many ways to search.

these ways is ok :

{  
"bool" : {  
"must" : {  
"query\_string" : {  
"query" : ""采莲新村"",  
"fields" : [ "name^200", "tags^5", "intra^1", "region^2",  
"address^2" ]  
}  
},  
"minimum\_should\_match" : "1"  
}  
}

{  
"bool" : {  
"must" : {  
"query\_string" : {  
"query" : "北京西路",  
"fields" : [ "name^200", "tags^5", "intra^1", "region^2",  
"address^2" ],  
"default\_operator" : "and"  
}  
},  
"minimum\_should\_match" : "1"  
}  
}

{  
"bool" : {  
"must" : {  
"query\_string" : {  
"query" : "北京西路",  
"fields" : [ "name^200", "tags^5", "intra^1", "region^2",  
"address^2" ]  
}  
},  
"minimum\_should\_match" : "1"  
}  
}

these is exception

{  
"bool" : {  
"must" : {  
"query\_string" : {  
"query" : ""北京西路"",  
"fields" : [ "name^200", "tags^5", "intra^1", "region^2",  
"address^2" ],  
"default\_operator" : "and"  
}  
},  
"minimum\_should\_match" : "1"  
}  
}  
,  
{  
"bool" : {  
"must" : {  
"query\_string" : {  
"query" : ""北京西路"",  
"fields" : [ "name^200", "tags^5", "intra^1", "region^2",  
"address^2" ]  
}  
},  
"minimum\_should\_match" : "1"  
}  
}

why ??  
在 2014年7月23日星期三UTC+8下午5时53分37秒，xu piao写道：

> i have one index with different \_type like  
> [http://localhost:9200/matrix/group](http://localhost:9200/matrix/group) and [http://localhost:9200/matrix/user](http://localhost:9200/matrix/user)
> 
> the two \_type all have 'region' field but with different type.  
> group :
> 
> - region: {
> - type: string
> - store: true
> - analyzer: ik  
> }
> 
> }
> 
> user:
> 
> - region: {
> - type: "long"  
> }
> 
> when 'matrix' index only have 'group' type.  
> i do search use 'query\_string' with multi\_field is ok
> 
> {  
> "bool" : {  
> "must" : {  
> "query\_string" : {  
> "query" : "北京西城",  
> "fields" : [ "name^20", "tags^5", "intra^1", "region^2",  
> "address^2" ]  
> }  
> },  
> "minimum\_should\_match" : "1"  
> }  
> }
> 
> but when i index 'user' type .do zhe same query it will throw exception
> 
> org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to  
> execute phase [query], all shards failed; shardFailures  
> {[\_vgvj\_11QpKOuZNo90nD\_A][matrix][0]: RemoteTransportException[[Blizzard  
> II][inet[/10.0.8.235:19300]][search/phase/query]]; nested:  
> QueryPhaseExecutionException[[matrix][0]: query[filtered((region:"北京  
> 西路"))-\>cache(\_type:group)],from[0],size[20]: Query Failed [Failed to  
> execute main query]]; nested: IllegalStateException[field "region" was  
> indexed without position data; cannot run PhraseQuery (term=北京)];  
> }{[\_vgvj\_11QpKOuZNo90nD\_A][matrix][4]: RemoteTransportException[[Blizzard  
> II][inet[/10.0.8.235:19300]][search/phase/query]]; nested:  
> QueryPhaseExecutionException[[matrix][4]: query[filtered((region:"北京  
> 西路"))-\>cache(\_type:group)],from[0],size[20]: Query Failed [Failed to  
> execute main query]]; nested: IllegalStateException[field "region" was  
> indexed without position data; cannot run PhraseQuery (term=北京)];  
> }{[\_vgvj\_11QpKOuZNo90nD\_A][matrix][3]: RemoteTransportException[[Blizzard  
> II][inet[/10.0.8.235:19300]][search/phase/query]]; nested:  
> QueryPhaseExecutionException[[matrix][3]: query[filtered((region:"北京  
> 西路"))-\>cache(\_type:group)],from[0],size[20]: Query Failed [Failed to  
> execute main query]]; nested: IllegalStateException[field "region" was  
> indexed without position data; cannot run PhraseQuery (term=北京)];  
> }{[3XK6HZ\_WSbG4E7Tot3mMMw][matrix][2]:  
> QueryPhaseExecutionException[[matrix][2]: query[filtered((region:"北京  
> 西路"))-\>cache(\_type:group)],from[0],size[20]: Query Failed [Failed to  
> execute main query]]; nested: IllegalStateException[field "region" was  
> indexed without position data; cannot run PhraseQuery (term=北京)];  
> }{[3XK6HZ\_WSbG4E7Tot3mMMw][matrix][1]:  
> QueryPhaseExecutionException[[matrix][1]: query[filtered((region:"北京  
> 西路"))-\>cache(\_type:group)],from[0],size[20]: Query Failed [Failed to  
> execute main query]]; nested: IllegalStateException[field "region" was  
> indexed without position data; cannot run PhraseQuery (term=北京)]; }  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.onFirstPhaseResult(TransportSearchTypeAction.java:276)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$3.onFailure(TransportSearchTypeAction.java:224)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:205)  
> at  
> org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:216)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$4.run(TransportSearchTypeAction.java:296)  
> at  
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)  
> at java.lang.Thread.run(Thread.java:722)
> 
> all my search request has assign type in java like :
> 
> SearchRequestBuilder searchRequest =  
> esClient.prepareSearch("matrix").setTypes("group")
> 
> .setSearchType(SearchType.QUERY\_THEN\_FETCH).setFrom(form).setSize(count).setExplain(true);
> 
> why ??

--  
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/9512aeef-5303-462f-a97a-38b549142f46%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9512aeef-5303-462f-a97a-38b549142f46%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:13am UTC](https://discuss.elastic.co/t/one-index-has-different--type-and-different--type-have-same-field-with-different-type-will-disturb/18817/5 "2017-07-06T01:13:37Z")

</div>


