Field query

I have the following section as part of my document - it represents "weakly
typed" custom fields.

  • customFields: [
    • {
      • id: 4055
      • class: DropDownCustomField
      • customFieldName: color
      • empty: false
      • fieldValueText: blue,orange,mauve
        }
    • {
      • id: 4056
      • class: DropDownCustomField
      • customFieldName: hue
      • empty: false
      • fieldValueText: red,blue
        }
        ]

How can I find a parent object (which has field customFileds) where custom
field color has 'blue' among its values. Currently, I am searching using
query string

customFieldName:color AND fieldValueText:blue

The problem with my approach that if the object has custom field 'color'
with value 'red' and custom field 'hue' with value 'blue', that object will
be among the hits. I need to make sure that field name and field value
belong to the same custom field (with id 4055 in my example).

How can I achieve that?

Thank you,

Michael

--

You need to index customFields as nested objectshttp://www.elasticsearch.org/guide/reference/mapping/nested-type.htmland wrap "customFieldName:color AND fieldValueText:blue" into a nested
queryhttp://www.elasticsearch.org/guide/reference/query-dsl/nested-query.html
.

On Friday, November 9, 2012 5:00:27 PM UTC-5, Michael Smolyak wrote:

I have the following section as part of my document - it represents
"weakly typed" custom fields.

  • customFields: [
    • {
      • id: 4055
      • class: DropDownCustomField
      • customFieldName: color
      • empty: false
      • fieldValueText: blue,orange,mauve
        }
    • {
      • id: 4056
      • class: DropDownCustomField
      • customFieldName: hue
      • empty: false
      • fieldValueText: red,blue
        }
        ]

How can I find a parent object (which has field customFileds) where custom
field color has 'blue' among its values. Currently, I am searching using
query string

customFieldName:color AND fieldValueText:blue

The problem with my approach that if the object has custom field 'color'
with value 'red' and custom field 'hue' with value 'blue', that object will
be among the hits. I need to make sure that field name and field value
belong to the same custom field (with id 4055 in my example).

How can I achieve that?

Thank you,

Michael

--