Facet search on nested fields


(Michael Smolyak) #1

Given a mapping and sample document below, I am trying to construct a
query, which would return facet information on the fields of the nested
objects (e.g., state.id or types.id). The mapping of serviceItem does not
used 'nested' type. How do I include a facet for "state.id" in the query.
When I include facets below, the one for 'launchUrl' returns results, while
the one for 'state.id' does not. How can obtain facet information on fields
of nested objects?

Thank you,

Michael

Facet fragment:

"facets": {
"tag1": {
"terms": {
"fields": [
"state.id"
]
}
},
"tag2": {
"terms": {
"fields": [
"launchUrl"
]
}
}
}

Mapping fragment:

serviceItem: {

  • properties: {
    • imageLargeUrl: {
      • include_in_all: true
      • index: not_analyzed
      • type: string
        }
    • totalComments: {
      • include_in_all: false
      • type: integer
        }
    • launchUrl: {
      • include_in_all: true
      • index: not_analyzed
      • type: string
        }
    • state: {
      • properties: {
        • id: {
          • include_in_all: false
          • index: no
          • type: long
            }
        • ref: {
          • include_in_all: false
          • index: no
          • type: string
            }
        • title: {
          • include_in_all: true
          • term_vector: with_positions_offsets
          • type: string
            }
        • isPublished: {
          • index: not_analyzed
          • type: boolean
            }
        • class: {
          • include_in_all: false
          • index: no
          • type: string
            }
            }
            }

A sample object:

{

}


(Michael Smolyak) #2

A correction to the original post:

I can facet on inner object fields that have unique names. For example,
facet on "itemComments.text" works fine, while the one on
"itemComments.class"

"facets": {
"text": {
"terms": {
"fields": [
"itemComments.class"
]
}
},

returns:

facets: {

  • text: {
    • _type: terms
    • missing: 46
    • total: 0
    • other: 0
    • terms: [ ]
      }

The only difference is that field 'text only occurs under itemComments,
while 'class' exists at other levels of object hierarchy. How do I deal
with inner fields whose names are not unique across the document?

I do not mind renaming or aliasing these fields, but I do not know how. I
am building the index using the Garls plugin, which gives rather limited
options for configuring mapping.

Michael

On Friday, May 25, 2012 2:03:34 PM UTC-4, Michael Smolyak wrote:

Given a mapping and sample document below, I am trying to construct a
query, which would return facet information on the fields of the nested
objects (e.g., state.id or types.id). The mapping of serviceItem does not
used 'nested' type. How do I include a facet for "state.id" in the query.
When I include facets below, the one for 'launchUrl' returns results, while
the one for 'state.id' does not. How can obtain facet information on
fields of nested objects?

Thank you,

Michael

Facet fragment:

"facets": {
"tag1": {
"terms": {
"fields": [
"state.id"
]
}
},
"tag2": {
"terms": {
"fields": [
"launchUrl"
]
}
}
}

Mapping fragment:

serviceItem: {

  • properties: {
    • imageLargeUrl: {
      • include_in_all: true
      • index: not_analyzed
      • type: string
        }
    • totalComments: {
      • include_in_all: false
      • type: integer
        }
    • launchUrl: {
      • include_in_all: true
      • index: not_analyzed
      • type: string
        }
    • state: {
      • properties: {
        • id: {
          • include_in_all: false
          • index: no
          • type: long
            }
        • ref: {
          • include_in_all: false
          • index: no
          • type: string
            }
        • title: {
          • include_in_all: true
          • term_vector: with_positions_offsets
          • type: string
            }
        • isPublished: {
          • index: not_analyzed
          • type: boolean
            }
        • class: {
          • include_in_all: false
          • index: no
          • type: string
            }
            }
            }

A sample object:

{

}


(system) #3