Optimize has_child query / filter


(kisi) #1

Hi,

i'm currently thinking if i could write a has_child filter differently to
performe a faster search.

I want all products (parents) with the term "printer" and which have set
the field "Client3.Type" to "K".

Currently i'm executing this query. But i think this way elasticsearch is
first searching for the query and then filtering the results. I would
preffere first to filter and then query the matching documents.

{

  • index: "columns",
  • type: "mainarticle",
  • body:
    {
    • query:
      {
      • has_child:
        {
        • type: "product",
        • query:
          {
          • filtered:
            {
            • query:
              {
              • multi_match:
                {
                • query: "printer",
                • fields:
                  [
                  • "Title",
                  • "Description"
                    ]
                    }
                    },
            • filter:
              {
              • and:
                [

                {
                - term:
                {
                - Client3.Type: "K"
                }
                }
                ]
                }
                }
                }
                }
                }
                }

}

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/80196832-a157-4347-8461-f64f8adbb188%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #2