solr OR fq not working

  • leninsuarez
    Participant
    # 3 weeks, 5 days ago

    Hello!

    I’m trying to query some posts using an OR filter

    type:resources OR is_resource_str:1

    If I use that single query in the solr dashboard I get the desired results,
    however I’m unable to set those parameters via php array or query string

    I’ve tried these options

    ‘wpsolr_fq[]’ => ‘type:resources||is_resource_str:1’,
    ‘wpsolr_fq’ => ‘type:resources||is_resource_str:1’,
    ‘wpsolr_fq’ => ‘type:resources OR is_resource_str:1’,

    Can you point me in the direction to achieve this?

    Thanks

    wpsolr
    Keymaster
    # 3 weeks, 5 days ago

    Hello,

    This is not a feature of the plugin. You can try to build add your filters with our hooks:

    Actions and Filters (Hooks)

    leninsuarez
    Participant
    # 1 week, 4 days ago

    Thanks for your answer, i was able to add this OR filter using the wpsolr_action_solarium_query hook, and then calling addFilterQuery function.

    Now my problem has gone to another direction, I have multiple searches running in the same page (planning to move to a grouped query if available), this is the steps I’m following to do this

    * I’m manually setting the value of $_SERVER[‘QUERY_STRING’] with the propper http query
    * I’m calling doing what the fun_search_indexed_data() function does in ajax_solr_services.php
    $_q = WPSOLR_Service_Container::get_query();
    $this->search_results = WPSOLR_Service_Container::get_solr_client()->get_results_data($_q);

    I also changed the class-wpsolr-abstractsearchclient.php file to disable cache for multiple searches running on the same page

    line 893 –> $results = $this->execute_wpsolr_query( $wpsolr_query, false );

    Using a solr instance this works just fine, but when I change to an AWS elasticsearch instance, my custom search breaks, I got results but query filters are not working.

    Do I need to do something else that I’m missing? Thanks!

    wpsolr
    Keymaster
    # 1 week, 4 days ago

    Be aware that the code you use is internal, and subject to change.

    Using a solr instance this works just fine, but when I change to an AWS elasticsearch instance, my custom search breaks, I got results but query filters are not working.

    It means the code detected a problem, and reverted to the standard WP search. Try to check your debug.log for errors.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.