I have a doubt at how to avoiding type gotchas


(xu piao) #1

http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/mapping.html#_avoiding_type_gotchas

at above guidence it say i can use _type + field name to avoid analyzer
conflicts. but i have try many times all is no use.

i have a index with two type is group and user which all have 'region'
field conflict .

group :

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

user:

  • region: {
    • type: "long"
      }

as guidence say :

We can avoid this problem either by naming the fields differently — eg
title_en and title_es — or by explicitly including the type name in the
field name and querying each field separately:

GET /_search
{
"query": {
"multi_match": { http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/mapping.html#CO30-1
"query": "The quick brown fox",
"fields": [ "blog_en.title", "blog_es.title" ]
}
}
}

I do query like this
{
"bool" : {
"must" : {
"query_string" : {
"query" : ""北京西路"",
"fields" : [ "group.name^20", "group.tags^5", "group.intra^1",
"group.region^2", "group.address^2" ]
}
},
"minimum_should_match" : "1"
}
}

but no use . it still throw exception .

why ???

exception :
org.elasticsearch.search.query.QueryPhaseExecutionException: [matrix][4]:
query[filtered((name:"闵行区 吴 宝 路"^20.0 | tags:"闵行区 吴 宝 路"^5.0 | intra:"闵行区 吴
宝 路" | region:"闵行区 吴 宝 路"^2.0 | address:"闵行区 吴 宝
路"^2.0))->cache(_type:group)],from[0],size[20]: 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.sendExecuteQuery(SearchServiceTransportAction.java:202)
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:292)
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.DisjunctionMaxQuery$DisjunctionMaxWeight.scorer(DisjunctionMaxQuery.java:161)
at
org.apache.lucene.search.FilteredQuery$RandomAccessFilterStrategy.filteredScorer(FilteredQuery.java:531)
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:491)
at
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:448)
at
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:281)
at
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:269)
at
org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:123)
... 8 more

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/5d8e0efc-da58-4a5f-a694-3357cf5d10d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Adrien Grand) #2

Hi,

The issue is that the region field in group is indexed with positional
data, while the region field in user is indexed without. This is
something that Elasticsearch cannot deal with. You should try to give the
region field different names in group and user.

On Fri, Jul 25, 2014 at 9:34 AM, xu piao xupiaobj@gmail.com wrote:

http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/mapping.html#_avoiding_type_gotchas

at above guidence it say i can use _type + field name to avoid analyzer
conflicts. but i have try many times all is no use.

i have a index with two type is group and user which all have 'region'
field conflict .

group :

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

user:

  • region: {
    • type: "long"
      }

as guidence say :

We can avoid this problem either by naming the fields differently — eg
title_en and title_es — or by explicitly including the type name in the
field name and querying each field separately:

GET /_search
{
"query": {
"multi_match": { http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/mapping.html#CO30-1
"query": "The quick brown fox",
"fields": [ "blog_en.title", "blog_es.title" ]
}
}
}

I do query like this
{
"bool" : {
"must" : {
"query_string" : {
"query" : ""北京西路"",
"fields" : [ "group.name^20", "group.tags^5", "group.intra^1",
"group.region^2", "group.address^2" ]
}
},
"minimum_should_match" : "1"
}
}

but no use . it still throw exception .

why ???

exception :
org.elasticsearch.search.query.QueryPhaseExecutionException: [matrix][4]:
query[filtered((name:"闵行区 吴 宝 路"^20.0 | tags:"闵行区 吴 宝 路"^5.0 | intra:"闵行区 吴
宝 路" | region:"闵行区 吴 宝 路"^2.0 | address:"闵行区 吴 宝
路"^2.0))->cache(_type:group)],from[0],size[20]: 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.sendExecuteQuery(SearchServiceTransportAction.java:202)
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:292)
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.DisjunctionMaxQuery$DisjunctionMaxWeight.scorer(DisjunctionMaxQuery.java:161)
at
org.apache.lucene.search.FilteredQuery$RandomAccessFilterStrategy.filteredScorer(FilteredQuery.java:531)
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:491)
at
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:448)
at
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:281)
at
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:269)
at
org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:123)
... 8 more

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/5d8e0efc-da58-4a5f-a694-3357cf5d10d8%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/5d8e0efc-da58-4a5f-a694-3357cf5d10d8%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
Adrien Grand

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7xpxcKpFv%2BzZpwY7EDyHwq-6aitAvght9BP2rCk4-86Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(xu piao) #3

Hi

Why it no use when i explicitly type name to separate query field ?

or that meanning : only two type 'region' field all indexed can use this
way to separate query field , not one of them is indexed can use?

sorry my english is poor .

Maybe I did not express clearly what I mean。

在 2014年7月26日星期六UTC+8上午1时16分25秒,Adrien Grand写道:

Hi,

The issue is that the region field in group is indexed with positional
data, while the region field in user is indexed without. This is
something that Elasticsearch cannot deal with. You should try to give the
region field different names in group and user.

On Fri, Jul 25, 2014 at 9:34 AM, xu piao <xupi...@gmail.com <javascript:>>
wrote:

http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/mapping.html#_avoiding_type_gotchas

at above guidence it say i can use _type + field name to avoid analyzer
conflicts. but i have try many times all is no use.

i have a index with two type is group and user which all have 'region'
field conflict .

group :

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

user:

  • region: {
    • type: "long"
      }

as guidence say :

We can avoid this problem either by naming the fields differently — eg
title_en and title_es — or by explicitly including the type name in the
field name and querying each field separately:

GET /_search
{

"query": {

    "multi_match": {  <http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/mapping.html#CO30-1>

        "query":    "The quick brown fox",

        "fields": [ "blog_en.title", "blog_es.title" ]

    }
}

}

I do query like this
{
"bool" : {
"must" : {
"query_string" : {
"query" : ""北京西路"",
"fields" : [ "group.name^20", "group.tags^5", "group.intra^1",
"group.region^2", "group.address^2" ]
}
},
"minimum_should_match" : "1"
}
}

but no use . it still throw exception .

why ???

exception :
org.elasticsearch.search.query.QueryPhaseExecutionException: [matrix][4]:
query[filtered((name:"闵行区 吴 宝 路"^20.0 | tags:"闵行区 吴 宝 路"^5.0 | intra:"闵行区 吴
宝 路" | region:"闵行区 吴 宝 路"^2.0 | address:"闵行区 吴 宝
路"^2.0))->cache(_type:group)],from[0],size[20]: 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.sendExecuteQuery(SearchServiceTransportAction.java:202)
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:292)
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.DisjunctionMaxQuery$DisjunctionMaxWeight.scorer(DisjunctionMaxQuery.java:161)
at
org.apache.lucene.search.FilteredQuery$RandomAccessFilterStrategy.filteredScorer(FilteredQuery.java:531)
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:491)
at
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:448)
at
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:281)
at
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:269)
at
org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:123)
... 8 more

--
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 <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/5d8e0efc-da58-4a5f-a694-3357cf5d10d8%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/5d8e0efc-da58-4a5f-a694-3357cf5d10d8%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
Adrien Grand

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/c51a8004-4e20-45e4-a487-c1a9886a254d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #4