Hi,
I'm trying to test a couple of things and I seem to be unable to match
filed value when this is indexed as boosted array type. Here's my metadata
(I use explicit dynamic mapping for all types and fields, because I need it
to boost individual fields during indexing and it's required based on docshttp://www.elasticsearch.org/guide/reference/mapping/core-types/ and
I don't know all the types and fields during index creation. I plan to add
some more explicit mappings in the future, for individual fields are know
about, but I hope it's not necessary now):
{
state: open
settings: {
index.number_of_shards: 5
index.number_of_replicas: 1
index.version.created: 200599
}
mappings: {
User: {
dynamic_templates: [
{
template_default: {
mapping: {
type: string
}
match: *
}
}
]
properties: {
uid: {
type: string
},
userName: {
type: string
},
userId: {
type: string
},
...
rolesIds:{
type: string
},
...
My test documents are indexed as:
{
_index: test
_type: User
_id: 123
_version: 1
_score: 1
_source: {
uid: {
_boost: 1
_value: 123
},
userName: {
_boost: 1
_value: Test Test
},
userId: {
_boost: 0
_value: 10196
},
...
roleIds: {
_boost: 1
_value: [
10161
10164
10165
]
}
}
}
Then a query like this does not return the user:
$ curl -XPOST url http://localhost:9200/test/_search?pretty=1 -d '
{"query":
{
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"query": {
"query_string": {
"query": "+(roleIds:10164)"
}
}
}
}
}
}
'
I would expect it to return the user, since the value is contained in the
rolesIds field array. When I use following term in the query_string, is
matches the user:
"query": "+(userId:10509)"
Also, when I change the User's fields to be indexed directly as arrays of
strings (omitting the object with _boost and _value, sacrificing the
boosting being indexed), like:
...
roleIds: [
10161
10164
10165
],
...
then the same query is matching correctly. Am I missing something or is it
some bug?
I choose to use filtered query, because I need to match documents based on
complicated (already parsed) Lucene queries. This seemed like the best
solution, since I do not form the Lucena queries manually, but already have
existing algorithms to create them. Also I need to use boosting of
individual fields during indexing, since some fields have no end-user
meaning while the other do (but again, I do not know the fields that are
gonna be indexed during index creation, so I cannot boost the whole field
in type definition and instread ned to boost the individual fields and
values when written to index).
Thanks for advice,
Josef
--
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.