-
Search Results
-
Topic: Elastic Search/Press
Hi Trevor,
I have Elastic search setup on server and working (I tested it with different queries). I also installed ElasticPress plugin. I would like now to integrate it with S&F. I read these two posts:
https://support.searchandfilter.com/forums/topic/algolia-vs-elastic-search-vs-search-filter-pro/
https://support.searchandfilter.com/forums/topic/working-with-elasticpress-elasticsearch/But could you please give more details how to use the sf_edit_query_args?
1) I am putting it in functions.php of the child theme but how the sfid is passed to it (is there a way to make sure it is passed correctly to the function)?
2) I am using for Display Results “Using shortcode”, and I am customising the results as mentioned here:
https://searchandfilter.com/documentation/search-results/using-a-shortcode/#customising-the-results
should I use another Display results method?3) I am using “Load results using Ajax”, should I disable it?
4) should I rebuild the cache of S&F after adding the above code to functions.php?
(Note I was using Relevanssi before but I disabled it now).5) Is there a way to test that the s&F is using ElasticPress?
Thanks,
AhmedHello,
I wanted to know if the Post Meta – Date field was compatible with the ACF Datetime field?
I set the “Date Input Format” option toYYYYMMDD (ACF)but it doesn’t work.If not, am I forced to split the date and the time?
I would like to avoid for my meta_query in “sf_edit_query_args” function:
function filter_function_name( $query_args, $sfid ) { if( $sfid == 73 ) { $now = current_time('Y-m-d H:i:s'); $query_args['meta_query'] = array( array( 'key' => 'live_datetime', 'value' => $now, 'compare' => '>', 'type' => 'DATETIME', ) ); } return $query_args; } add_filter('sf_edit_query_args', 'filter_function_name', 20, 2);Thanks in advance!
Hi,
I need to filter the query, I need to get a filter that returns posts with meta “price” higher than value that user has filtered. I have tried this code, but is not working. Can you help me please?
function filter_function_name( $query_args, $sfid ) {
if($sfid==858){
if(isset($_GET[‘_sfm_m2_from’]) && !isset($_GET[‘_sfm_price_from’])){
$query_args[‘meta_query’] = array(
array(
‘key’ => ‘m2_from’,
‘value’ => $_GET[‘_sfm_m2_from’],
‘compare’ => ‘>=’,
‘type’ => ‘NUMERIC’,
),
);}
if(isset($_GET[‘_sfm_price_from’]) && !isset($_GET[‘_sfm_m2_from’])){
$query_args[‘meta_query’] = array(
array(
‘key’ => ‘price_from’,
‘value’ => $_GET[‘_sfm_price_from’],
‘compare’ => ‘>=’,
‘type’ => ‘NUMERIC’,
),
);}
if(isset($_GET[‘_sfm_m2_from’]) && isset($_GET[‘_sfm_price_from’])){
$query_args[‘meta_query’] = array(
‘relation’ => ‘AND’,
array(
‘key’ => ‘m2_from’,
‘value’ => $_GET[‘_sfm_m2_from’],
‘compare’ => ‘>=’,
‘type’ => ‘NUMERIC’,
),
array(
‘key’ => ‘price_from’,
‘value’ => $_GET[‘_sfm_price_from’],
‘compare’ => ‘>=’,
‘type’ => ‘NUMERIC’,
),
);}
}
return $query_args;
}
add_filter( ‘sf_edit_query_args’, ‘filter_function_name’, 20, 2 );Regards
Hallo,
We have a piece of code that checks for a custom query string added in the url from another page.
Our code that works:
function filter_shop_tags($query_args, $sfid) { if ($sfid==112 && isset($_GET['shop-tag']) && !empty($_GET['shop-tag'])) { $query_args['tax_query'] = array( array( 'taxonomy' => 'shop_tag', 'field' => 'slug', 'terms' => array( $_GET['shop-tag'] ), ), ); } return $query_args; } add_filter('sf_edit_query_args', 'filter_shop_tags', 20, 2);The anchor from another page is example.com/shops/?shop-tag=exampleTag.
On the shops page we have the S&F filter. (Which is correctly filtered with the function). But when we try to active another filter with S&F. Another taxonomy for example it remove the ?shop-tag query string and turns into example.com/shops/?shop-taxonomy=exampleTax, but my wish would be: example.com/shops/?shop-tag=exampleTag&shop-taxonomy=exampleTax
regards
My search had been working fine yesterday. Today I made a few changes, then removed those changes but I cannot get this to work again: https://finigan.org/
You will see the $query_args because I am dumping them from the edit query args filter(shown below)
These query_args don’t seem to match what the search is set up to do. I have a CPT called Poetry Node with ACFs poet_name and poem_name and 6 kinds of node_resources(these act like categories). I have the relationship set to OR in the general settings of the Search form, query_args below say AND. Id of search is 119. Results are As an Archive using index.php. It was working but earlier today I made a duplicate of this search retaining only the poet_name in the form – everything else was the same (except the searchId). I have since deleted that Search form but I’m wondering if that messed something up. I have rebuilt the cache. I’m stumped.function ffp_edit_query_args( $query_args, $sfid ) { //if search form ID = 225, the do something with this query echo "<pre>"; var_dump($sfid); echo "</pre>"; //if($sfid==204) /* poem_name search */ //{ //modify $query_args here before returning it //$query_args['somearg'] = 'newvalue'; echo "<pre>"; var_dump($query_args); echo "</pre>"; //} return $query_args; } add_filter( 'sf_edit_query_args', 'ffp_edit_query_args', 20, 2 );