WordPress.org

Forums

Fantastic ElasticSearch
[resolved] How to use the facet filter to do a range query (4 posts)

  1. Marko Heijnen
    Member
    Posted 1 year ago #

    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/

  2. Paris Holley
    Member
    Plugin Author

    Posted 1 year ago #

    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 );

  3. Paris Holley
    Member
    Plugin Author

    Posted 1 year ago #

    sorry correction

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

  4. Marko Heijnen
    Member
    Posted 1 year ago #

    Awesome that works better.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Fantastic ElasticSearch
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.