0

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!

3
  • I'll guess this is elastic search. If it is so, you should mention that. Commented May 6, 2013 at 15:02
  • Sorry but I don't quite get what you want to achieve. What would you expect as a result? Commented May 6, 2013 at 17:56
  • I need is to find a word in all content, but filter by idtipooa. Commented May 7, 2013 at 15:33

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

9 Comments

I tried: { "filtered" : { "query" : { "match_all" : {} }, "filter" : { "nested" : { "path" : "idtipooa", "query" : { "bool" : { "must" : [ { "match" : {"idtipooa.nombre" : "Universitaria"} } ] } }, "_cache" : true } } } }It has not worked
That should work. Please, add a complete example with some sample data to your question.
{"_index":"website","_type":"ofertas","_id":"3","_score":0.32260805, "_source" : {"id":3,"nombreoa":"Abogacia","titulo":"Abogado","duracion":"5","uniduracion":"As","email":"[email protected]","caracteristicas":"El abitraje\n","matricula":"2196","cuota":2196,"estado":"V","dirigidoa":null,"url":null,"idareaestudio":{"nombre":"Abogacia"},"idcategoria":{"nombre":"Abogada"},"idinstitucion":{"nombreinstitucion":"UDE - Universidad de la Empresa","nombresede":"Central"},"idmodalidadoa":{"nombre":"Presencial"},"idniveloa":{"nombre":"Grado"},"idtipooa":{"nombre":"Carrera Universitaria"}}
Rebe, I just tested it with your data and pieces of your mapping - it works. gist.github.com/imotov/737176fd5a0f60730db8 Make sure that mapping is applied correctly to your index.
I expected the results to be zero, because I consult "Universitaria" and not "Carrera Universitaria"
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.