# Matching values in array with boost factor indexed

**URL:** <https://discuss.elastic.co/t/matching-values-in-array-with-boost-factor-indexed/11337>\
**Category:** Elasticsearch\
**Created:** [March 27, 2013, 2:55pm UTC](https://discuss.elastic.co/t/matching-values-in-array-with-boost-factor-indexed/11337 "2013-03-27T14:55:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josef\_Sustacek](https://avatars.discourse-cdn.com/v4/letter/j/977dab/32.png) [@Josef\_Sustacek](https://discuss.elastic.co/u/Josef_Sustacek)\
**Post date:** [March 27, 2013, 2:55pm UTC](https://discuss.elastic.co/t/matching-values-in-array-with-boost-factor-indexed/11337/1 "2013-03-27T14:55:41Z")

</div>

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 docs[http://www.elasticsearch.org/guide/reference/mapping/core-types/](http://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](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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:44am UTC](https://discuss.elastic.co/t/matching-values-in-array-with-boost-factor-indexed/11337/2 "2017-07-06T02:44:09Z")

</div>


