Exact match problem - one of fields of multi_field mapping not be 'not_analyzed'

Hi guys,
I have a mapping like below to match exact value for _value field but
_value field is analyzed.
'not_analyzed' option works very well right under the properties like
'_type' field, but under the 'multi_field' type it doesn't work.
am i doing something wrong? or is there a workaround to match exact value
for value field?
thanks guys in advance.

"internal":{
"_index":{
"enabled":true
},
"_id":{
"index":"not_analyzed",
"store":"yes",
"path" :"_uid"
},
"properties":{
"_type" : {"type":"string","index":"not_analyzed","store":"yes"},
"_fields" : {
"properties":{
"$name":{
"type":"multi_field",
"fields":{
"$name" : {"type" : "string", "index" : "not_analyzed"},
"type" : {"type" : "integer", "index" : "not_analyzed"},
"_value" : {"type" : "string", "index" : "not_analyzed"},
"value" : {"type" : "string", "index" : "analyzed"}
}
}
}
}
}
}

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Marcus

I have a mapping like below to match exact value for _value field but
_value field is analyzed.
'not_analyzed' option works very well right under the properties like
'_type' field, but under the 'multi_field' type it doesn't work.
am i doing something wrong? or is there a workaround to match exact
value for value field?

You can definitely use not_analyzed in a multi-field. Please can you
gist a complete recreation of what you are doing (neatly formatted) so
that it demonstrates why you think it doesn't work.

ta

clint

thanks guys in advance.

"internal":{
"_index":{
"enabled":true
},
"_id":{
"index":"not_analyzed",
"store":"yes",
"path" :"_uid"
},
"properties":{
"_type" : {"type":"string","index":"not_analyzed","store":"yes"},
"_fields" : {
"properties":{
"$name":{
"type":"multi_field",
"fields":{
"$name" : {"type" : "string", "index" : "not_analyzed"},
"type" : {"type" : "integer", "index" : "not_analyzed"},
"_value" : {"type" : "string", "index" : "not_analyzed"},
"value" : {"type" : "string", "index" : "analyzed"}
}
}
}
}
}
}

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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Clinton,
thank you for your reply.
here's my gist https://gist.github.com/mintbass/5044004 for sample mapping
and sample data.
the _fields is dynamically changed by data types so i need the multi_field
mapping and i want _value field not to be analyzed.
I'm not so sure for this case which way is the best for mapping and
indexing data.
thanks.

2013년 2월 26일 화요일 오후 7시 10분 33초 UTC+9, Clinton Gormley 님의 말:

Hi Marcus

I have a mapping like below to match exact value for _value field but
_value field is analyzed.
'not_analyzed' option works very well right under the properties like
'_type' field, but under the 'multi_field' type it doesn't work.
am i doing something wrong? or is there a workaround to match exact
value for value field?

You can definitely use not_analyzed in a multi-field. Please can you
gist a complete recreation of what you are doing (neatly formatted) so
that it demonstrates why you think it doesn't work.

ta

clint

thanks guys in advance.

"internal":{
"_index":{
"enabled":true
},
"_id":{
"index":"not_analyzed",
"store":"yes",
"path" :"_uid"
},
"properties":{
"_type" : {"type":"string","index":"not_analyzed","store":"yes"},
"_fields" : {
"properties":{
"$name":{
"type":"multi_field",
"fields":{
"$name" : {"type" : "string", "index" : "not_analyzed"},
"type" : {"type" : "integer", "index" : "not_analyzed"},
"_value" : {"type" : "string", "index" : "not_analyzed"},
"value" : {"type" : "string", "index" : "analyzed"}
}
}
}
}
}
}

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:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Marcus

thank you for your reply.
here's my gist https://gist.github.com/mintbass/5044004 for sample
mapping and sample data.

Just as a side note, you are specifying that the _id should be extracted
from the field _uid in your documents, but you're not passing a _uid.

Also, in general, don't use field names beginning with an underscore, as
these are reserved for internal Elasticsearch field names, and you may
end up with a conflict.

the _fields is dynamically changed by data types so i need the
multi_field mapping and i want _value field not to be analyzed.

Then, you have completely misunderstood how multi-fields work. And you
can't have dynamic field names represented by "$name" - it just won't
work.

A multi-field expects to receive a single key/value pair, eg
{"my_field": "my value"}
and then it will index "myvalue" in one or more ways. For instance:

{ my_field: {
type: "multi_field",
fields: {
my_field: { type: "string" },
raw: { type: "string", index: "not_analyzed" }
}
}

If you index a document like { "my_field": "my value" } then you will
have two searchable fields:

  • "my_field.my_field" (also accessible as "my_field")
    containing terms ["my","value"]
  • "my_field.raw"
    containing the term ["my value"]

You can use "dynamic templates"
Elasticsearch Platform — Find real-time answers at scale | Elastic to auto-map new fields, but it would be much simpler to just define the field types ahead of time.

clint

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

I resolved this issue using object type and template mapping.
Thanks a lot clint.

On Wednesday, February 27, 2013 7:49:57 PM UTC+9, Clinton Gormley wrote:

Hi Marcus

thank you for your reply.
here's my gist https://gist.github.com/mintbass/5044004 for sample
mapping and sample data.

Just as a side note, you are specifying that the _id should be extracted
from the field _uid in your documents, but you're not passing a _uid.

Also, in general, don't use field names beginning with an underscore, as
these are reserved for internal Elasticsearch field names, and you may
end up with a conflict.

the _fields is dynamically changed by data types so i need the
multi_field mapping and i want _value field not to be analyzed.

Then, you have completely misunderstood how multi-fields work. And you
can't have dynamic field names represented by "$name" - it just won't
work.

A multi-field expects to receive a single key/value pair, eg
{"my_field": "my value"}
and then it will index "myvalue" in one or more ways. For instance:

{ my_field: {
type: "multi_field",
fields: {
my_field: { type: "string" },
raw: { type: "string", index: "not_analyzed" }
}
}

If you index a document like { "my_field": "my value" } then you will
have two searchable fields:

  • "my_field.my_field" (also accessible as "my_field")
    containing terms ["my","value"]
  • "my_field.raw"
    containing the term ["my value"]

You can use "dynamic templates"
Elasticsearch Platform — Find real-time answers at scale | Elastic auto-map new fields, but it would be much simpler to just define the
field types ahead of time.

clint

--
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.
For more options, visit https://groups.google.com/groups/opt_out.