Support » Plugin: Fantastic ElasticSearch » How to use the facet filter to do a range query

  • Resolved Marko Heijnen

    (@markoheijnen)


    Currently I use the filter ‘searcher_query_post_facet_filter’ to add the following argument:

    $args[‘query’][‘filtered’][‘filter’][‘range’][‘meta_price’] = array( ‘from’ => 30, ‘to’ => 70 );

    Except when I do this the information I get back is different. The major thing is that I don’t get any counts back. My Elasticsearch skills are still limited so I guess I use the wrong way of filtering.

    This example is used for a price range slider so the range isn’t static.

    http://wordpress.org/plugins/fantastic-elasticsearch/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Paris Holley

    (@parisholley)

    when I do ranges in the plugin, I use this syntax. give it a shot and see if it helps. create an issue on github to maybe add a helper api in the plugin to build this for you.

    $args[‘query’][‘bool’][‘must’][‘range’][‘field’] = array( ‘from’ => 30, ‘to’ => 70 );

    Plugin Author Paris Holley

    (@parisholley)

    sorry correction

    $args[‘query’][‘bool’][‘must’][] = array(‘range’ => array( ‘field’ = array( ‘from’ => 30, ‘to’ => 70 )));

    Thread Starter Marko Heijnen

    (@markoheijnen)

    Awesome that works better.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to use the facet filter to do a range query’ is closed to new replies.