Search sort using a field with an "index_name" results in "No mapping found"

I ran into this problem, and discovered this StackOverflow post (with no
answer):

That original poster included a gist that reproduces it quite nicely
(confirmed on 1.4.1):

Partially replicated here for convenience (see the link for full curl steps
to reproduce):

Create mapping

curl -XPOST localhost:9200/index1/ -d '{
"mappings": {
"people": {
"properties": {
"work_email": {
"type": "string",
"index_name": "email",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}'

Basically, I have an analyzed string field and a non-analyzed version of it
so that I can sort by it. But instead of sorting by "field.sort" or
"field.raw", I need to use "field_sort", basically for back compat reasons.
To accomplish that I tried giving the non-analyzed sortable version of the
string field an index_name. But trying to sort using the given index_name
results in an error: "No mapping found for [field_sort] in order to sort
on".

The gist referenced above is slightly different than I am explaining,
because it puts the "index_name" on the parent field instead of the sorted
part, but the result is the same.

To put it simply, it seems that you cannot sort by a field by its
index_name, you have to use the full path to it, which is a problem for me.
Is this expected? Why should I be able to search for a field by its
index_name but not sort by it -- that seems unintended. Am I doing it
wrong? Is there a better way to accomplish the same thing?

Thanks for the help!

--
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/af25ab54-407b-4e58-95ea-94c12fb3fb65%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

What happen if you try:

"mappings": {
"people": {
"properties": {
"work_email": {
"type": "string",
"index_name": "email",
"fields": {
"raw": {
"type": "string",
"index_name": "email.raw",
"index": "not_analyzed"
}
}
}
}
}
}
}'

Does this work?

David

Le 12 déc. 2014 à 01:12, Dave Reed infinity88@gmail.com a écrit :

I ran into this problem, and discovered this StackOverflow post (with no answer):
elasticsearch index_name with multi_field - Stack Overflow

That original poster included a gist that reproduces it quite nicely (confirmed on 1.4.1):
sorting_by_aliased_field.sh · GitHub

Partially replicated here for convenience (see the link for full curl steps to reproduce):

Create mapping

curl -XPOST localhost:9200/index1/ -d '{
"mappings": {
"people": {
"properties": {
"work_email": {
"type": "string",
"index_name": "email",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}'

Basically, I have an analyzed string field and a non-analyzed version of it so that I can sort by it. But instead of sorting by "field.sort" or "field.raw", I need to use "field_sort", basically for back compat reasons. To accomplish that I tried giving the non-analyzed sortable version of the string field an index_name. But trying to sort using the given index_name results in an error: "No mapping found for [field_sort] in order to sort on".

The gist referenced above is slightly different than I am explaining, because it puts the "index_name" on the parent field instead of the sorted part, but the result is the same.

To put it simply, it seems that you cannot sort by a field by its index_name, you have to use the full path to it, which is a problem for me. Is this expected? Why should I be able to search for a field by its index_name but not sort by it -- that seems unintended. Am I doing it wrong? Is there a better way to accomplish the same thing?

Thanks for the help!

--
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/af25ab54-407b-4e58-95ea-94c12fb3fb65%40googlegroups.com.
For more options, visit 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/3887D2C8-924B-40C5-94E0-5CFEEA98436A%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.

I see you tried adding index_name to the inner field as well. Nope, I'm
afraid that did not work.

Anyone have any thoughts here? This definitely seems like a bug :slight_smile:

On Thursday, December 11, 2014 10:12:02 PM UTC-8, David Pilato wrote:

What happen if you try:

"mappings": {
"people": {
"properties": {
"work_email": {
"type": "string",
"index_name": "email",
"fields": {
"raw": {
"type": "string",
"index_name": "email.raw",
"index": "not_analyzed"
}
}
}
}
}
}
}'

Does this work?

David

Le 12 déc. 2014 à 01:12, Dave Reed <infin...@gmail.com <javascript:>> a
écrit :

I ran into this problem, and discovered this StackOverflow post (with no
answer):

elasticsearch index_name with multi_field - Stack Overflow

That original poster included a gist that reproduces it quite nicely
(confirmed on 1.4.1):
sorting_by_aliased_field.sh · GitHub

Partially replicated here for convenience (see the link for full curl
steps to reproduce):

Create mapping

curl -XPOST localhost:9200/index1/ -d '{
"mappings": {
"people": {
"properties": {
"work_email": {
"type": "string",
"index_name": "email",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}'

Basically, I have an analyzed string field and a non-analyzed version of
it so that I can sort by it. But instead of sorting by "field.sort" or
"field.raw", I need to use "field_sort", basically for back compat reasons.
To accomplish that I tried giving the non-analyzed sortable version of the
string field an index_name. But trying to sort using the given index_name
results in an error: "No mapping found for [field_sort] in order to sort
on".

The gist referenced above is slightly different than I am explaining,
because it puts the "index_name" on the parent field instead of the sorted
part, but the result is the same.

To put it simply, it seems that you cannot sort by a field by its
index_name, you have to use the full path to it, which is a problem for me.
Is this expected? Why should I be able to search for a field by its
index_name but not sort by it -- that seems unintended. Am I doing it
wrong? Is there a better way to accomplish the same thing?

Thanks for the help!

--
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/af25ab54-407b-4e58-95ea-94c12fb3fb65%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/af25ab54-407b-4e58-95ea-94c12fb3fb65%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/71f2a195-b6b1-4666-93df-517603d568ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Just in the interest of having a two-way link, I opened a github issue
about it here:

On Monday, December 15, 2014 9:41:01 AM UTC-8, Dave Reed wrote:

I see you tried adding index_name to the inner field as well. Nope, I'm
afraid that did not work.

Anyone have any thoughts here? This definitely seems like a bug :slight_smile:

--
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/648de326-80eb-402e-91a0-32ccc57ba7ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.