Rebe
Rebe

Reputation: 13

Find all Filtered by Nested in elasticsearch

I want to make a query, looking all equal to "something" but other than that I can filter by fields: "idcategoria", "idinstitucion" and "idtipooa".

fos_elastica:
clients:
    default: { host: localhost, port: 9200 }
indexes:
    website:
        client: default
        types:
             ofertas:
                 mappings:
                     id: { boost: 3 }
                     nombreoa: { analyzer: snowball }
                     titulo: {boost: 3}
                     duracion: {boost: 3}
                     uniduracion: {boost: 3}
                     email: {boost: 3}
                     caracteristicas: { analyzer: snowball }
                     requisitos: ~
                     planestudio: ~
                     matricula: {boost: 3}
                     cuota: {boost: 3}
                     estado: {boost: 3}
                     dirigidoa: {boost: 3}
                     url: {boost: 3}
                     idareaestudio:
                        type: "nested"
                        properties:
                            nombre: { boost: 5 }
                     idcategoria:
                        type: "nested"
                        properties:
                            nombre: { boost: 5 }
                     idinstitucion:
                        type: "nested"
                        properties:
                            nombreinstitucion: { boost: 5 }      
                            nombresede: { boost: 5 }
                     idmodalidadoa:
                        type: "nested"
                        properties:
                            nombre: { boost: 5 }  
                     idniveloa:
                        type: "nested"
                        properties:
                            nombre: { boost: 5 } 
                     idtipooa:
                        type: "nested"
                        properties:
                            nombre: { boost: 5 }                   
                 persistence:
                    driver: orm
                    model: FrontEnd\AplicacionBundle\Entity\Oa
                    provider: ~
                    finder: ~
                    repository: FrontEnd\AplicacionBundle\Repository\OaRepository

I tried:

> { 
"query": {
    "filtered": {
          "query":  {  "text": { "_all":   "Aboga"}},
   "filter": {  "term": { "idtipooa.nombre": "Universitaria" }}
}
}}

But it has not worked. Please if anyone can help ... Thank you!

Upvotes: 0

Views: 1387

Answers (1)

imotov
imotov

Reputation: 30163

idtipooa is a nested field, so in order to search it you need to wrap your term filter into nested filter.

Upvotes: 1

Related Questions