When do you need large heap for Elasticsearch?

What's a tutorial or resource that can explain the DSL pattern in Elasticsearch, so that I can understand it better?

  • ElasticSearch Query params (DSL query) I have been working with the ElasticSearch from last few months, but still find it complicated when I have to pass an complicated query. I want to run the query which will have to search the multiple "types" and each type has to be searched with its own "filters", but need to have combined "searched results" for example: i need to search the "user type" document which are my friends and on the same time i have to search the "object type" document which I like, according to the keyword provided. OR The query that has both the "AND" and "NOT" clause Example query:     $options['query'] = array(             'query' => array(                 'filtered' => array(                     'query' => array(                         'query_string' => array(                             'default_field' => 'name',                             'query' => $this->search_term . '*',                         ),                     ),                     'filter' => array(                         'and' => array(                             array(                                 'term' => array(                                     'access_id' => 2,                                 ),                             ),                         ),                         'not' => array(                             array(                                 'term' => array(                                     'follower' => 32,                                 ),                             ),                             array(                                 'term' => array(                                     'fan' => 36,                                 ),                             ),                         ),                     ),                 ),             ),         ); and $options['query'] = array(         'query' => array(             'filtered' => array(                 'query' => array(                     'query_string' => array(                         'default_field' => 'name',                         'query' => $this->search_term . '*',                     ),                 ),                 'filters' => array(                     array(                         'filter' => array(                             'term' => array('access_id' => 2),                         ),                     ),                     array(                         'filter' => array(                             'not' => array(                                     'term' => array(                                         'follower_of_inverse' => 32,                                     ),                             ),                         ),                     ),                 ),             ),         ),     ); in the second query  i have little success but when i pass the send filter for not.. it doesn't works. as this query is meant to search the user with access_id = 2, but must not have the follower of id 32 and fan of id 36 but this is not working.. Please help thanks.

  • Answer:

    I believe I can help for your first example. I ran into the same problem of wanting to return multiple types from multiple queries, and I came up with two solutions. You could join the individualized type queries in a bool query as 'should' clauses. bool query documentation:http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html Design your queries as if you were only querying one item type each to come up with a "user query" and an "object query". Then, embed them as should clauses in a boolean query with a type filter. Gist of the json:https://gist.github.com/1386569 However, this has the problem of comparing different item types and scoring schemes, meaning that it is possible for the results of the query to be all one type or all the other type. For me, this was undesirable, so I ended up issuing both queries asynchronously and joining the results myself, giving me more control over how many of each type of result. Hope this helps!

Brian Humphrey at Quora Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.