Not_analyzed attribute ==> Can't sort on string types with more than one value per doc, or more than one token per field


(nherment) #1

Hi,

First, hello as It's my first post on this group :slight_smile: I'm seeking your
help as I've been banging my head against an issue with ES (version
0.18.6).

The issue when I sort on a not_analyzed string attribute.

I get the following error:
QueryPhaseExecutionException[[system][2]: query[filtered(name:new*)-

FilterCacheFilterWrapper(_type:UILayout)],from[0],size[15],sort[<custom:
"name":
org.elasticsearch.index.field.data.strings.StringFieldDataType
$1@6f172517>]:
Query Failed [Failed to execute main query]];
nested: IOException[Can't sort on string types with more than one
value per doc, or more than one token per field];

I have a "name" attribute with index=not_analyzed. There are a certain
mumber of objects put into ES with "name" attribute ranging from
"newA" to "newX".
The name attribute is unique.

When I do a search query with the query string "name:new*", all
entities get returned. I on top of that query I sort on the name
attribute, I get the error mentioned above. I don't know what I'm
doing wrong so I'm seeking your help 0:-)

I created a gist with the mapping details, a non sortless query and a
sort query: https://gist.github.com/2158124#

Thanks,

  • Nicolas

(Ivan Brusic) #2

Are you sure that your name attribute is unique? ElasticSearch cannot
sort on a multi-valued field.

However, looking at your query, it appears you are attempting to do a
wildcard query on a non-analyzed field. Not sure if this scenario
would cause the error your indicate, but your results would not be
correct.

query_string queries go through the analyzer. A prefix query is needed
for non analyzed fields:

http://www.elasticsearch.org/guide/reference/query-dsl/prefix-query.html

--
Ivan

On Thu, Mar 22, 2012 at 6:08 AM, nicolas nherment@gmail.com wrote:

Hi,

First, hello as It's my first post on this group :slight_smile: I'm seeking your
help as I've been banging my head against an issue with ES (version
0.18.6).

The issue when I sort on a not_analyzed string attribute.

I get the following error:
QueryPhaseExecutionException[[system][2]: query[filtered(name:new*)-

FilterCacheFilterWrapper(_type:UILayout)],from[0],size[15],sort[<custom:
"name":
org.elasticsearch.index.field.data.strings.StringFieldDataType
$1@6f172517>]:
Query Failed [Failed to execute main query]];
nested: IOException[Can't sort on string types with more than one
value per doc, or more than one token per field];

I have a "name" attribute with index=not_analyzed. There are a certain
mumber of objects put into ES with "name" attribute ranging from
"newA" to "newX".
The name attribute is unique.

When I do a search query with the query string "name:new*", all
entities get returned. I on top of that query I sort on the name
attribute, I get the error mentioned above. I don't know what I'm
doing wrong so I'm seeking your help 0:-)

I created a gist with the mapping details, a non sortless query and a
sort query: https://gist.github.com/2158124#

Thanks,

  • Nicolas

(nherment) #3

Hi Ivan,

I didn't know that the query string was going against the analyzer.

So I ran the following query:
curl -XPOST -d '{"from" : 0, "size" : 15, "query":{"prefix":
{"name":"new"} },"sort" : [{"name":"asc"}]}'
http://localhost:9200/system/UILayout/_search?pretty=true
Using the prefix, as you said.

However I still have the "multiple values per doc" error.

I'm sure the "name" attribute is unique in my mapping since it is
returning only one name field, right ?
[...]
"name": {
"index": "not_analyzed",
"store": "yes",
"type": "string"
},
[...]

Which query can I run to make sure the "name" attribute is unique ?

Thanks for your help :slight_smile:

  • Nicolas

On Mar 23, 12:48 am, Ivan Brusic i...@brusic.com wrote:

Are you sure that your name attribute is unique? ElasticSearch cannot
sort on a multi-valued field.

However, looking at your query, it appears you are attempting to do a
wildcard query on a non-analyzed field. Not sure if this scenario
would cause the error your indicate, but your results would not be
correct.

query_string queries go through the analyzer. A prefix query is needed
for non analyzed fields:

http://www.elasticsearch.org/guide/reference/query-dsl/prefix-query.html

--
Ivan

On Thu, Mar 22, 2012 at 6:08 AM, nicolas nherm...@gmail.com wrote:

Hi,

First, hello as It's my first post on this group :slight_smile: I'm seeking your
help as I've been banging my head against an issue with ES (version
0.18.6).

The issue when I sort on a not_analyzed string attribute.

I get the following error:
QueryPhaseExecutionException[[system][2]: query[filtered(name:new*)-

FilterCacheFilterWrapper(_type:UILayout)],from[0],size[15],sort[<custom:
"name":
org.elasticsearch.index.field.data.strings.StringFieldDataType
$1@6f172517>]:
Query Failed [Failed to execute main query]];
nested: IOException[Can't sort on string types with more than one
value per doc, or more than one token per field];

I have a "name" attribute with index=not_analyzed. There are a certain
mumber of objects put into ES with "name" attribute ranging from
"newA" to "newX".
The name attribute is unique.

When I do a search query with the query string "name:new*", all
entities get returned. I on top of that query I sort on the name
attribute, I get the error mentioned above. I don't know what I'm
doing wrong so I'm seeking your help 0:-)

I created a gist with the mapping details, a non sortless query and a
sort query:https://gist.github.com/2158124#

Thanks,

  • Nicolas

(Shay Banon) #4

If you have multiple values under name, then you will get the error. Can
you gist a sample of your data that you index?

On Monday, March 26, 2012 11:26:39 AM UTC+2, nicolas wrote:

Hi Ivan,

I didn't know that the query string was going against the analyzer.

So I ran the following query:
curl -XPOST -d '{"from" : 0, "size" : 15, "query":{"prefix":
{"name":"new"} },"sort" : [{"name":"asc"}]}'
http://localhost:9200/system/UILayout/_search?pretty=true
Using the prefix, as you said.

However I still have the "multiple values per doc" error.

I'm sure the "name" attribute is unique in my mapping since it is
returning only one name field, right ?
[...]
"name": {
"index": "not_analyzed",
"store": "yes",
"type": "string"
},
[...]

Which query can I run to make sure the "name" attribute is unique ?

Thanks for your help :slight_smile:

  • Nicolas

On Mar 23, 12:48 am, Ivan Brusic i...@brusic.com wrote:

Are you sure that your name attribute is unique? ElasticSearch cannot
sort on a multi-valued field.

However, looking at your query, it appears you are attempting to do a
wildcard query on a non-analyzed field. Not sure if this scenario
would cause the error your indicate, but your results would not be
correct.

query_string queries go through the analyzer. A prefix query is needed
for non analyzed fields:

http://www.elasticsearch.org/guide/reference/query-dsl/prefix-query.html

--
Ivan

On Thu, Mar 22, 2012 at 6:08 AM, nicolas nherm...@gmail.com wrote:

Hi,

First, hello as It's my first post on this group :slight_smile: I'm seeking your
help as I've been banging my head against an issue with ES (version
0.18.6).

The issue when I sort on a not_analyzed string attribute.

I get the following error:
QueryPhaseExecutionException[[system][2]: query[filtered(name:new*)-

FilterCacheFilterWrapper(_type:UILayout)],from[0],size[15],sort[<custom:
"name":
org.elasticsearch.index.field.data.strings.StringFieldDataType
$1@6f172517>]:
Query Failed [Failed to execute main query]];
nested: IOException[Can't sort on string types with more than one
value per doc, or more than one token per field];

I have a "name" attribute with index=not_analyzed. There are a certain
mumber of objects put into ES with "name" attribute ranging from
"newA" to "newX".
The name attribute is unique.

When I do a search query with the query string "name:new*", all
entities get returned. I on top of that query I sort on the name
attribute, I get the error mentioned above. I don't know what I'm
doing wrong so I'm seeking your help 0:-)

I created a gist with the mapping details, a non sortless query and a
sort query:https://gist.github.com/2158124#

Thanks,

  • Nicolas

(nherment) #5

Here it is:

Thanks,

  • Nicolas

On Apr 4, 5:10 pm, kimchy kim...@gmail.com wrote:

If you have multiple values under name, then you will get the error. Can
you gist a sample of your data that you index?

On Monday, March 26, 2012 11:26:39 AM UTC+2, nicolas wrote:

Hi Ivan,

I didn't know that the query string was going against the analyzer.

So I ran the following query:
curl -XPOST -d '{"from" : 0, "size" : 15, "query":{"prefix":
{"name":"new"} },"sort" : [{"name":"asc"}]}'
http://localhost:9200/system/UILayout/_search?pretty=true
Using the prefix, as you said.

However I still have the "multiple values per doc" error.

I'm sure the "name" attribute is unique in my mapping since it is
returning only one name field, right ?
[...]
"name": {
"index": "not_analyzed",
"store": "yes",
"type": "string"
},
[...]

Which query can I run to make sure the "name" attribute is unique ?

Thanks for your help :slight_smile:

  • Nicolas

On Mar 23, 12:48 am, Ivan Brusic i...@brusic.com wrote:

Are you sure that your name attribute is unique? ElasticSearch cannot
sort on a multi-valued field.

However, looking at your query, it appears you are attempting to do a
wildcard query on a non-analyzed field. Not sure if this scenario
would cause the error your indicate, but your results would not be
correct.

query_string queries go through the analyzer. A prefix query is needed
for non analyzed fields:

http://www.elasticsearch.org/guide/reference/query-dsl/prefix-query.html

--
Ivan

On Thu, Mar 22, 2012 at 6:08 AM, nicolas nherm...@gmail.com wrote:

Hi,

First, hello as It's my first post on this group :slight_smile: I'm seeking your
help as I've been banging my head against an issue with ES (version
0.18.6).

The issue when I sort on a not_analyzed string attribute.

I get the following error:
QueryPhaseExecutionException[[system][2]: query[filtered(name:new*)-

FilterCacheFilterWrapper(_type:UILayout)],from[0],size[15],sort[<custom:
"name":
org.elasticsearch.index.field.data.strings.StringFieldDataType
$1@6f172517>]:
Query Failed [Failed to execute main query]];
nested: IOException[Can't sort on string types with more than one
value per doc, or more than one token per field];

I have a "name" attribute with index=not_analyzed. There are a certain
mumber of objects put into ES with "name" attribute ranging from
"newA" to "newX".
The name attribute is unique.

When I do a search query with the query string "name:new*", all
entities get returned. I on top of that query I sort on the name
attribute, I get the error mentioned above. I don't know what I'm
doing wrong so I'm seeking your help 0:-)

I created a gist with the mapping details, a non sortless query and a
sort query:https://gist.github.com/2158124#

Thanks,

  • Nicolas

(Shay Banon) #6

It does not seem like you have several values for name, so I am not sure
how you get it. Can you gist a full curl recreation, with index creation,
setting the mapping, indexing sample data, and showing the problem? My
guess is that you either index a doc with multiple name values by mistake.

On Wed, Apr 4, 2012 at 6:37 PM, nicolas nherment@gmail.com wrote:

Here it is:
https://gist.github.com/2302869

Thanks,

  • Nicolas

On Apr 4, 5:10 pm, kimchy kim...@gmail.com wrote:

If you have multiple values under name, then you will get the error. Can
you gist a sample of your data that you index?

On Monday, March 26, 2012 11:26:39 AM UTC+2, nicolas wrote:

Hi Ivan,

I didn't know that the query string was going against the analyzer.

So I ran the following query:
curl -XPOST -d '{"from" : 0, "size" : 15, "query":{"prefix":
{"name":"new"} },"sort" : [{"name":"asc"}]}'
http://localhost:9200/system/UILayout/_search?pretty=true
Using the prefix, as you said.

However I still have the "multiple values per doc" error.

I'm sure the "name" attribute is unique in my mapping since it is
returning only one name field, right ?
[...]
"name": {
"index": "not_analyzed",
"store": "yes",
"type": "string"
},
[...]

Which query can I run to make sure the "name" attribute is unique ?

Thanks for your help :slight_smile:

  • Nicolas

On Mar 23, 12:48 am, Ivan Brusic i...@brusic.com wrote:

Are you sure that your name attribute is unique? ElasticSearch cannot
sort on a multi-valued field.

However, looking at your query, it appears you are attempting to do a
wildcard query on a non-analyzed field. Not sure if this scenario
would cause the error your indicate, but your results would not be
correct.

query_string queries go through the analyzer. A prefix query is
needed

for non analyzed fields:

http://www.elasticsearch.org/guide/reference/query-dsl/prefix-query.html

--
Ivan

On Thu, Mar 22, 2012 at 6:08 AM, nicolas nherm...@gmail.com wrote:

Hi,

First, hello as It's my first post on this group :slight_smile: I'm seeking
your

help as I've been banging my head against an issue with ES (version
0.18.6).

The issue when I sort on a not_analyzed string attribute.

I get the following error:
QueryPhaseExecutionException[[system][2]:
query[filtered(name:new*)-

FilterCacheFilterWrapper(_type:UILayout)],from[0],size[15],sort[<custom:

"name":
org.elasticsearch.index.field.data.strings.StringFieldDataType
$1@6f172517>]:
Query Failed [Failed to execute main query]];
nested: IOException[Can't sort on string types with more than one
value per doc, or more than one token per field];

I have a "name" attribute with index=not_analyzed. There are a
certain

mumber of objects put into ES with "name" attribute ranging from
"newA" to "newX".
The name attribute is unique.

When I do a search query with the query string "name:new*", all
entities get returned. I on top of that query I sort on the name
attribute, I get the error mentioned above. I don't know what I'm
doing wrong so I'm seeking your help 0:-)

I created a gist with the mapping details, a non sortless query
and a

sort query:https://gist.github.com/2158124#

Thanks,

  • Nicolas

(nherment) #7

Hi,

Sorry for the delay of my answer.

Here is a list of curl command to reproduce the issue (also there's a
gist here: https://gist.github.com/2402313).
Indeed there is multiple name values but for an entity on a different
mapping. Shouldn't the mappings be independent from each other ?

init the index

curl -XPUT 'http://localhost:9200/system/' -d '{ "settings" :
{ "index" : {"number_of_replicas" : 1 } } }'

create the Layout and UILayout mappings. Note that both have "name"

property and one is analyzed, the other is not.
curl -XPUT 'http://localhost:9200/system/Layout/_mapping' -d
'{"Layout":{"properties":{"name":
{"type":"string","index":"analyzed","store":"yes"}}}}'
curl -XPUT 'http://localhost:9200/system/UILayout/_mapping' -d
'{"UILayout":{"properties":{"name":
{"type":"string","index":"not_analyzed","store":"yes"}}}}'

insert a new entity with analyzed field (multi values)

curl -XPUT 'http://localhost:9200/system/Layout/main-layout' -d
'{"name":"main-layout"}'

Search against the not analyzed field

curl -XPOST 'http://localhost:9200/system/UILayout/_search' -d
'{"sort":[{"name":"sac"}],"query":{"term":{"name":"foobar"}}}'

Returns this error:
{"took":4,"timed_out":false,"_shards":{"total":5,"successful":
4,"failed":1,"failures":[{"index":"system","shard":2,"status":
500,"reason":"QueryPhaseExecutionException[[system][2]:
query[filtered(name:foobar)-

FilterCacheFilterWrapper(_type:UILayout)],from[0],size[10],sort[<custom:
"name":
org.elasticsearch.index.field.data.strings.StringFieldDataType
$1@346df9bc>]: Query Failed [Failed to execute main query]]; nested:
IOException[Can't sort on string types with more than one value per
doc, or more than one token per field]; "}]},"hits":{"total":
0,"max_score":null,"hits":[]}}

Is this expected ES behavior or is it a bug ? I would have expected
that the indexing of 2 different mappings would be independent.

Thanks,

  • Nicolas

On Apr 4, 8:44 am, Shay Banon kim...@gmail.com wrote:

It does not seem like you have several values for name, so I am not sure
how you get it. Can you gist a full curl recreation, with index creation,
setting the mapping, indexing sample data, and showing the problem? My
guess is that you either index a doc with multiple name values by mistake.

On Wed, Apr 4, 2012 at 6:37 PM, nicolas nherm...@gmail.com wrote:

Here it is:
https://gist.github.com/2302869

Thanks,

  • Nicolas

On Apr 4, 5:10 pm, kimchy kim...@gmail.com wrote:

If you have multiple values under name, then you will get the error. Can
you gist a sample of your data that you index?

On Monday, March 26, 2012 11:26:39 AM UTC+2, nicolas wrote:

Hi Ivan,

I didn't know that the query string was going against the analyzer.

So I ran the following query:
curl -XPOST -d '{"from" : 0, "size" : 15, "query":{"prefix":
{"name":"new"} },"sort" : [{"name":"asc"}]}'
http://localhost:9200/system/UILayout/_search?pretty=true
Using the prefix, as you said.

However I still have the "multiple values per doc" error.

I'm sure the "name" attribute is unique in my mapping since it is
returning only one name field, right ?
[...]
"name": {
"index": "not_analyzed",
"store": "yes",
"type": "string"
},
[...]

Which query can I run to make sure the "name" attribute is unique ?

Thanks for your help :slight_smile:

  • Nicolas

On Mar 23, 12:48 am, Ivan Brusic i...@brusic.com wrote:

Are you sure that your name attribute is unique? ElasticSearch cannot
sort on a multi-valued field.

However, looking at your query, it appears you are attempting to do a
wildcard query on a non-analyzed field. Not sure if this scenario
would cause the error your indicate, but your results would not be
correct.

query_string queries go through the analyzer. A prefix query is
needed

for non analyzed fields:

http://www.elasticsearch.org/guide/reference/query-dsl/prefix-query.html

--
Ivan

On Thu, Mar 22, 2012 at 6:08 AM, nicolas nherm...@gmail.com wrote:

Hi,

First, hello as It's my first post on this group :slight_smile: I'm seeking
your

help as I've been banging my head against an issue with ES (version
0.18.6).

The issue when I sort on a not_analyzed string attribute.

I get the following error:
QueryPhaseExecutionException[[system][2]:
query[filtered(name:new*)-

FilterCacheFilterWrapper(_type:UILayout)],from[0],size[15],sort[<custom:

"name":
org.elasticsearch.index.field.data.strings.StringFieldDataType
$1@6f172517>]:
Query Failed [Failed to execute main query]];
nested: IOException[Can't sort on string types with more than one
value per doc, or more than one token per field];

I have a "name" attribute with index=not_analyzed. There are a
certain

mumber of objects put into ES with "name" attribute ranging from
"newA" to "newX".
The name attribute is unique.

When I do a search query with the query string "name:new*", all
entities get returned. I on top of that query I sort on the name
attribute, I get the error mentioned above. I don't know what I'm
doing wrong so I'm seeking your help 0:-)

I created a gist with the mapping details, a non sortless query
and a

sort query:https://gist.github.com/2158124#

Thanks,

  • Nicolas

(Shay Banon) #8

Same named fields across different types need to have the same type / index
behavior when sorting / faceting on them, so thats the problem.

On Tue, Apr 17, 2012 at 2:35 AM, nicolas nherment@gmail.com wrote:

Hi,

Sorry for the delay of my answer.

Here is a list of curl command to reproduce the issue (also there's a
gist here: https://gist.github.com/2402313).
Indeed there is multiple name values but for an entity on a different
mapping. Shouldn't the mappings be independent from each other ?

init the index

curl -XPUT 'http://localhost:9200/system/' -d '{ "settings" :
{ "index" : {"number_of_replicas" : 1 } } }'

create the Layout and UILayout mappings. Note that both have "name"

property and one is analyzed, the other is not.
curl -XPUT 'http://localhost:9200/system/Layout/_mapping' -d
'{"Layout":{"properties":{"name":
{"type":"string","index":"analyzed","store":"yes"}}}}'
curl -XPUT 'http://localhost:9200/system/UILayout/_mapping' -d
'{"UILayout":{"properties":{"name":
{"type":"string","index":"not_analyzed","store":"yes"}}}}'

insert a new entity with analyzed field (multi values)

curl -XPUT 'http://localhost:9200/system/Layout/main-layout' -d
'{"name":"main-layout"}'

Search against the not analyzed field

curl -XPOST 'http://localhost:9200/system/UILayout/_search' -d
'{"sort":[{"name":"sac"}],"query":{"term":{"name":"foobar"}}}'

Returns this error:
{"took":4,"timed_out":false,"_shards":{"total":5,"successful":
4,"failed":1,"failures":[{"index":"system","shard":2,"status":
500,"reason":"QueryPhaseExecutionException[[system][2]:
query[filtered(name:foobar)-

FilterCacheFilterWrapper(_type:UILayout)],from[0],size[10],sort[<custom:
"name":
org.elasticsearch.index.field.data.strings.StringFieldDataType
$1@346df9bc>]: Query Failed [Failed to execute main query]]; nested:
IOException[Can't sort on string types with more than one value per
doc, or more than one token per field]; "}]},"hits":{"total":
0,"max_score":null,"hits":[]}}

Is this expected ES behavior or is it a bug ? I would have expected
that the indexing of 2 different mappings would be independent.

Thanks,

  • Nicolas

On Apr 4, 8:44 am, Shay Banon kim...@gmail.com wrote:

It does not seem like you have several values for name, so I am not sure
how you get it. Can you gist a full curl recreation, with index creation,
setting the mapping, indexing sample data, and showing the problem? My
guess is that you either index a doc with multiple name values by
mistake.

On Wed, Apr 4, 2012 at 6:37 PM, nicolas nherm...@gmail.com wrote:

Here it is:
https://gist.github.com/2302869

Thanks,

  • Nicolas

On Apr 4, 5:10 pm, kimchy kim...@gmail.com wrote:

If you have multiple values under name, then you will get the error.
Can

you gist a sample of your data that you index?

On Monday, March 26, 2012 11:26:39 AM UTC+2, nicolas wrote:

Hi Ivan,

I didn't know that the query string was going against the analyzer.

So I ran the following query:
curl -XPOST -d '{"from" : 0, "size" : 15, "query":{"prefix":
{"name":"new"} },"sort" : [{"name":"asc"}]}'
http://localhost:9200/system/UILayout/_search?pretty=true
Using the prefix, as you said.

However I still have the "multiple values per doc" error.

I'm sure the "name" attribute is unique in my mapping since it is
returning only one name field, right ?
[...]
"name": {
"index": "not_analyzed",
"store": "yes",
"type": "string"
},
[...]

Which query can I run to make sure the "name" attribute is unique ?

Thanks for your help :slight_smile:

  • Nicolas

On Mar 23, 12:48 am, Ivan Brusic i...@brusic.com wrote:

Are you sure that your name attribute is unique? ElasticSearch
cannot

sort on a multi-valued field.

However, looking at your query, it appears you are attempting to
do a

wildcard query on a non-analyzed field. Not sure if this scenario
would cause the error your indicate, but your results would not
be

correct.

query_string queries go through the analyzer. A prefix query is
needed

for non analyzed fields:

http://www.elasticsearch.org/guide/reference/query-dsl/prefix-query.html

--
Ivan

On Thu, Mar 22, 2012 at 6:08 AM, nicolas nherm...@gmail.com
wrote:

Hi,

First, hello as It's my first post on this group :slight_smile: I'm seeking
your

help as I've been banging my head against an issue with ES
(version

0.18.6).

The issue when I sort on a not_analyzed string attribute.

I get the following error:
QueryPhaseExecutionException[[system][2]:
query[filtered(name:new*)-

FilterCacheFilterWrapper(_type:UILayout)],from[0],size[15],sort[<custom:

"name":
org.elasticsearch.index.field.data.strings.StringFieldDataType
$1@6f172517>]:
Query Failed [Failed to execute main query]];
nested: IOException[Can't sort on string types with more than
one

value per doc, or more than one token per field];

I have a "name" attribute with index=not_analyzed. There are a
certain

mumber of objects put into ES with "name" attribute ranging
from

"newA" to "newX".
The name attribute is unique.

When I do a search query with the query string "name:new*", all
entities get returned. I on top of that query I sort on the
name

attribute, I get the error mentioned above. I don't know what
I'm

doing wrong so I'm seeking your help 0:-)

I created a gist with the mapping details, a non sortless query
and a

sort query:https://gist.github.com/2158124#

Thanks,

  • Nicolas

(nherment) #9

Ok, thanks. That makes sense now.

I'll go the "multi_field" way for all our entities and redirect sorts
against the untouched field as described here:
http://blog.wiercinski.net/2011/uncategorized/elasticsearch-sorting-on-string-types-with-more-than-one-value-per-doc-or-more-than-one-token-per-field/

On Apr 17, 6:22 am, Shay Banon kim...@gmail.com wrote:

Same named fields across different types need to have the same type / index
behavior when sorting / faceting on them, so thats the problem.

On Tue, Apr 17, 2012 at 2:35 AM, nicolas nherm...@gmail.com wrote:

Hi,

Sorry for the delay of my answer.

Here is a list of curl command to reproduce the issue (also there's a
gist here:https://gist.github.com/2402313).
Indeed there is multiple name values but for an entity on a different
mapping. Shouldn't the mappings be independent from each other ?

init the index

curl -XPUT 'http://localhost:9200/system/'-d '{ "settings" :
{ "index" : {"number_of_replicas" : 1 } } }'

create the Layout and UILayout mappings. Note that both have "name"

property and one is analyzed, the other is not.
curl -XPUT 'http://localhost:9200/system/Layout/_mapping'-d
'{"Layout":{"properties":{"name":
{"type":"string","index":"analyzed","store":"yes"}}}}'
curl -XPUT 'http://localhost:9200/system/UILayout/_mapping'-d
'{"UILayout":{"properties":{"name":
{"type":"string","index":"not_analyzed","store":"yes"}}}}'

insert a new entity with analyzed field (multi values)

curl -XPUT 'http://localhost:9200/system/Layout/main-layout'-d
'{"name":"main-layout"}'

Search against the not analyzed field

curl -XPOST 'http://localhost:9200/system/UILayout/_search'-d
'{"sort":[{"name":"sac"}],"query":{"term":{"name":"foobar"}}}'

Returns this error:
{"took":4,"timed_out":false,"_shards":{"total":5,"successful":
4,"failed":1,"failures":[{"index":"system","shard":2,"status":
500,"reason":"QueryPhaseExecutionException[[system][2]:
query[filtered(name:foobar)-

FilterCacheFilterWrapper(_type:UILayout)],from[0],size[10],sort[<custom:
"name":
org.elasticsearch.index.field.data.strings.StringFieldDataType
$1@346df9bc>]: Query Failed [Failed to execute main query]]; nested:
IOException[Can't sort on string types with more than one value per
doc, or more than one token per field]; "}]},"hits":{"total":
0,"max_score":null,"hits":[]}}

Is this expected ES behavior or is it a bug ? I would have expected
that the indexing of 2 different mappings would be independent.

Thanks,

  • Nicolas

On Apr 4, 8:44 am, Shay Banon kim...@gmail.com wrote:

It does not seem like you have several values for name, so I am not sure
how you get it. Can you gist a full curl recreation, with index creation,
setting the mapping, indexing sample data, and showing the problem? My
guess is that you either index a doc with multiple name values by
mistake.

On Wed, Apr 4, 2012 at 6:37 PM, nicolas nherm...@gmail.com wrote:

Here it is:
https://gist.github.com/2302869

Thanks,

  • Nicolas

On Apr 4, 5:10 pm, kimchy kim...@gmail.com wrote:

If you have multiple values under name, then you will get the error.
Can

you gist a sample of your data that you index?

On Monday, March 26, 2012 11:26:39 AM UTC+2, nicolas wrote:

Hi Ivan,

I didn't know that the query string was going against the analyzer.

So I ran the following query:
curl -XPOST -d '{"from" : 0, "size" : 15, "query":{"prefix":
{"name":"new"} },"sort" : [{"name":"asc"}]}'
http://localhost:9200/system/UILayout/_search?pretty=true
Using the prefix, as you said.

However I still have the "multiple values per doc" error.

I'm sure the "name" attribute is unique in my mapping since it is
returning only one name field, right ?
[...]
"name": {
"index": "not_analyzed",
"store": "yes",
"type": "string"
},
[...]

Which query can I run to make sure the "name" attribute is unique ?

Thanks for your help :slight_smile:

  • Nicolas

On Mar 23, 12:48 am, Ivan Brusic i...@brusic.com wrote:

Are you sure that your name attribute is unique? ElasticSearch
cannot

sort on a multi-valued field.

However, looking at your query, it appears you are attempting to
do a

wildcard query on a non-analyzed field. Not sure if this scenario
would cause the error your indicate, but your results would not
be

correct.

query_string queries go through the analyzer. A prefix query is
needed

for non analyzed fields:

http://www.elasticsearch.org/guide/reference/query-dsl/prefix-query.html

--
Ivan

On Thu, Mar 22, 2012 at 6:08 AM, nicolas nherm...@gmail.com
wrote:

Hi,

First, hello as It's my first post on this group :slight_smile: I'm seeking
your

help as I've been banging my head against an issue with ES
(version

0.18.6).

The issue when I sort on a not_analyzed string attribute.

I get the following error:
QueryPhaseExecutionException[[system][2]:
query[filtered(name:new*)-

FilterCacheFilterWrapper(_type:UILayout)],from[0],size[15],sort[<custom:

"name":
org.elasticsearch.index.field.data.strings.StringFieldDataType
$1@6f172517>]:
Query Failed [Failed to execute main query]];
nested: IOException[Can't sort on string types with more than
one

value per doc, or more than one token per field];

I have a "name" attribute with index=not_analyzed. There are a
certain

mumber of objects put into ES with "name" attribute ranging
from

"newA" to "newX".
The name attribute is unique.

When I do a search query with the query string "name:new*", all
entities get returned. I on top of that query I sort on the
name

attribute, I get the error mentioned above. I don't know what
I'm

doing wrong so I'm seeking your help 0:-)

I created a gist with the mapping details, a non sortless query
and a

sort query:https://gist.github.com/2158124#

Thanks,

  • Nicolas

(system) #10