Searching on multi-field fields


(datadev) #1

Hi,

I have an index with a multi-field field using the example in
http://www.elasticsearch.org/guide/reference/mapping/multi-field-type.html

{
"tweet" : {
"properties" : {
"name" : {
"type" : "multi_field",
"fields" : {
"name" : {"type" : "string", "index" :
"analyzed"},
"untouched" : {"type" : "string", "index" :
"not_analyzed"}
}
}
}
}
}

However, I can't seem to successful query nor perform faceting on the
multi-field.

EG: http://localhost:9200/twitter/tweet/_search?q=name.untouched:*
(using 'name.untouched' as recommended in
http://www.elasticsearch.org/guide/reference/mapping/multi-field-type.html)
returns no results.

Is my syntax incorrect, or does multi-field fields not support
querying (but that would not make sense)?


(datadev) #2

To provide more detail:

http://localhost:9200/twitter/tweet/_search?fields=name.untouched&q=*
works in that all docs are retrieved with only the name.untouched
field, but http://localhost:9200/twitter/tweet/_search?fields=name.untouched&q=name.untouched:*
does not work.

Is this a bug?

On Oct 17, 3:55 pm, datadev n...@adinfocenter.com wrote:

Hi,

I have an index with a multi-field field using the example inhttp://www.elasticsearch.org/guide/reference/mapping/multi-field-type...

{
"tweet" : {
"properties" : {
"name" : {
"type" : "multi_field",
"fields" : {
"name" : {"type" : "string", "index" :
"analyzed"},
"untouched" : {"type" : "string", "index" :
"not_analyzed"}
}
}
}
}

}

However, I can't seem to successful query nor perform faceting on the
multi-field.

EG:http://localhost:9200/twitter/tweet/_search?q=name.untouched:*
(using 'name.untouched' as recommended inhttp://www.elasticsearch.org/guide/reference/mapping/multi-field-type...)
returns no results.

Is my syntax incorrect, or does multi-field fields not support
querying (but that would not make sense)?


(Shay Banon) #3

You can't ask for name.untouched to be returned as its not stored, and not
part of the json to be extracted from. When you ask for a field to be
returned, it either needs to be stored, or, it needs to be a valid path
"into" the source json document.

On Mon, Oct 17, 2011 at 10:49 PM, datadev nji@adinfocenter.com wrote:

To provide more detail:

http://localhost:9200/twitter/tweet/_search?fields=name.untouched&q=*
works in that all docs are retrieved with only the name.untouched
field, but
http://localhost:9200/twitter/tweet/_search?fields=name.untouched&q=name.untouched:*
does not work.

Is this a bug?

On Oct 17, 3:55 pm, datadev n...@adinfocenter.com wrote:

Hi,

I have an index with a multi-field field using the example inhttp://
www.elasticsearch.org/guide/reference/mapping/multi-field-type...

{
"tweet" : {
"properties" : {
"name" : {
"type" : "multi_field",
"fields" : {
"name" : {"type" : "string", "index" :
"analyzed"},
"untouched" : {"type" : "string", "index" :
"not_analyzed"}
}
}
}
}

}

However, I can't seem to successful query nor perform faceting on the
multi-field.

EG:http://localhost:9200/twitter/tweet/_search?q=name.untouched:*
(using 'name.untouched' as recommended inhttp://
www.elasticsearch.org/guide/reference/mapping/multi-field-type...)
returns no results.

Is my syntax incorrect, or does multi-field fields not support
querying (but that would not make sense)?


(datadev) #4

Hi Shay,

The name.untouched is stored. When I do q=*, the name.untouched values
do show up in the result set, and I can also limit the returned field
values to only name.untouched via fields=name.untouched.

The problem is that I get an empty result set when I do
q=name.untouched:*

Do I have the incorrect query syntax or maybe this is a bug?

On Oct 17, 8:08 pm, Shay Banon kim...@gmail.com wrote:

You can't ask for name.untouched to be returned as its not stored, and not
part of the json to be extracted from. When you ask for a field to be
returned, it either needs to be stored, or, it needs to be a valid path
"into" the source json document.

On Mon, Oct 17, 2011 at 10:49 PM, datadev n...@adinfocenter.com wrote:

To provide more detail:

http://localhost:9200/twitter/tweet/_search?fields=name.untouched&q=*
works in that all docs are retrieved with only the name.untouched
field, but
http://localhost:9200/twitter/tweet/_search?fields=name.untouched&q=n...
does not work.

Is this a bug?

On Oct 17, 3:55 pm, datadev n...@adinfocenter.com wrote:

Hi,

I have an index with a multi-field field using the example inhttp://
www.elasticsearch.org/guide/reference/mapping/multi-field-type...

{
"tweet" : {
"properties" : {
"name" : {
"type" : "multi_field",
"fields" : {
"name" : {"type" : "string", "index" :
"analyzed"},
"untouched" : {"type" : "string", "index" :
"not_analyzed"}
}
}
}
}

}

However, I can't seem to successful query nor perform faceting on the
multi-field.

EG:http://localhost:9200/twitter/tweet/_search?q=name.untouched:*
(using 'name.untouched' as recommended inhttp://
www.elasticsearch.org/guide/reference/mapping/multi-field-type...)
returns no results.

Is my syntax incorrect, or does multi-field fields not support
querying (but that would not make sense)?


(Shay Banon) #5

Heya, this seems to work: https://gist.github.com/1296043. Maybe you can
change it to show the problem you are having?

On Tue, Oct 18, 2011 at 2:39 AM, datadev nji@adinfocenter.com wrote:

Hi Shay,

The name.untouched is stored. When I do q=*, the name.untouched values
do show up in the result set, and I can also limit the returned field
values to only name.untouched via fields=name.untouched.

The problem is that I get an empty result set when I do
q=name.untouched:*

Do I have the incorrect query syntax or maybe this is a bug?

On Oct 17, 8:08 pm, Shay Banon kim...@gmail.com wrote:

You can't ask for name.untouched to be returned as its not stored, and
not
part of the json to be extracted from. When you ask for a field to be
returned, it either needs to be stored, or, it needs to be a valid path
"into" the source json document.

On Mon, Oct 17, 2011 at 10:49 PM, datadev n...@adinfocenter.com wrote:

To provide more detail:

http://localhost:9200/twitter/tweet/_search?fields=name.untouched&q=*
works in that all docs are retrieved with only the name.untouched
field, but
http://localhost:9200/twitter/tweet/_search?fields=name.untouched&q=n.
..

does not work.

Is this a bug?

On Oct 17, 3:55 pm, datadev n...@adinfocenter.com wrote:

Hi,

I have an index with a multi-field field using the example inhttp://
www.elasticsearch.org/guide/reference/mapping/multi-field-type...

{
"tweet" : {
"properties" : {
"name" : {
"type" : "multi_field",
"fields" : {
"name" : {"type" : "string", "index" :
"analyzed"},
"untouched" : {"type" : "string", "index" :
"not_analyzed"}
}
}
}
}

}

However, I can't seem to successful query nor perform faceting on the
multi-field.

EG:http://localhost:9200/twitter/tweet/_search?q=name.untouched:*
(using 'name.untouched' as recommended inhttp://
www.elasticsearch.org/guide/reference/mapping/multi-field-type...)
returns no results.

Is my syntax incorrect, or does multi-field fields not support
querying (but that would not make sense)?


(rlong) #6

I am also experiencing this same behavior. None of the multi-fields are coming back in a query result. I can view the values in a q=: but if I do a q=parent.child:* it doesn't return anything. This is the exact same behavior explained above in this article. Even when I copy the code at https://gist.github.com/1296043 verbatim, I am still not able to get back any results.

Is there some type of configuration that has to be done?

Thanks!

rlong


(rlong) #7

Here is the test scenario I am trying to conduct:

curl -XPUT localhost:9200/6 -d '{
"mappings" : {
"type1" : {
"properties" : {
"name" : {
"type" : "multi_field",
"fields" : {
"name" : {"type" : "string", "index" : "analyzed"},
"untouched" : {"type" : "string", "index" : "not_analyzed"}
}
}
}
}
}
}'

curl -XPUT localhost:9200/6/type1/1 -d '{
"name" : {"name":"test me","untouched":"test1"}
}'

curl -XPUT localhost:9200/6/type1/2 -d '{
"name" : {"name":"test me","untouched":"test2"}
}'

curl -XPUT localhost:9200/6/type1/3 -d '{
"name" : {"name":"test me","untouched":"test3"}
}'

curl -XPOST localhost:9200/6/_refresh

This returns all 3 documents:

curl -XPUT localhost:9200/6/type1/_search?q=name.untouched:*

This returns nothing:

curl -XPUT localhost:9200/6/type1/_search?q=name.untouched:test3


(Shay Banon) #8

I think you misunderstood what multi field is for. The idea of multi field
is that for the same json field value (in your case, name), it will be
indexed in two different manners, one under "name", and one under
"name.untouched". In your case, you have two *different" json fields,
"name", and "untouched", with different values. So you should simply have
two different mappings for those.

On Thu, Oct 20, 2011 at 9:53 PM, rlong rlliii@hotmail.com wrote:

Here is the test scenario I am trying to conduct:

curl -XPUT localhost:9200/6 -d '{
"mappings" : {
"type1" : {
"properties" : {
"name" : {
"type" : "multi_field",
"fields" : {
"name" : {"type" : "string", "index" : "analyzed"},
"untouched" : {"type" : "string", "index" : "not_analyzed"}
}
}
}
}
}
}'

curl -XPUT localhost:9200/6/type1/1 -d '{
"name" : {"name":"test me","untouched":"test1"}
}'

curl -XPUT localhost:9200/6/type1/2 -d '{
"name" : {"name":"test me","untouched":"test2"}
}'

curl -XPUT localhost:9200/6/type1/3 -d '{
"name" : {"name":"test me","untouched":"test3"}
}'

curl -XPOST localhost:9200/6/_refresh

This returns all 3 documents:

curl -XPUT localhost:9200/6/type1/_search?q=name.untouched:*

This returns nothing:

curl -XPUT localhost:9200/6/type1/_search?q=name.untouched:test3

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/Searching-on-multi-field-fields-tp3429284p3438812.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.


(system) #9