Forum Replies Created
-
wpsolrKeymaster3 years, 11 months ago in reply to: WP Search with Algolia and wpsolr fatal error #31419
I do not think you can.
You’ll have to choose one plugin over the other.
wpsolrKeymaster3 years, 11 months ago in reply to: WP Search with Algolia and wpsolr fatal error #31408Both plugins use the same Algolia’s php client library, but probably not with the same version. Hence the error.
wpsolrKeymaster3 years, 11 months ago in reply to: Boost Search on Taxonomy Pages #31404Something like that should work:
<?php use wpsolr\core\classes\ui\WPSOLR_Query; use wpsolr\core\classes\WPSOLR_Events; add_action( WPSOLR_Events::WPSOLR_FILTER_UPDATE_WPSOLR_QUERY, 'update_keywords', 10, 1 ); /** * * Update the WPSOLR keywords based on some conditions. * * @param WPSOLR_Query $wpsolr_query * * @return WPSOLR_Query */ function update_keywords( WPSOLR_Query $wpsolr_query ) { $current_keywords = $wpsolr_query->get_wpsolr_query(); /** * Change keywords based on your conditions here */ if ( 'test' === $current_keywords ) { $wpsolr_query->set_wpsolr_query( 'trial' ); } return $wpsolr_query; }wpsolrKeymaster3 years, 11 months ago in reply to: how to set word variations #31398Here is a workaround to configure a synonyms file on a WPSOLR index. You will need to reindex all your data after this procedure, and every time you update the synonyms file.
1. Install your synonym.txt file in your Elasticsearch server’s elasticsearch/config/analysis/ folder
2. Create a new index from Kibana with the command:PUT /my_new_index { "settings": { "analysis": { "filter": { "english_stop": { "type": "stop", "stopwords": "_english_" }, "english_stemmer": { "type": "stemmer", "language": "english" }, "english_possessive_stemmer": { "type": "stemmer", "language": "possessive_english" }, "synonym": { "type": "synonym_graph", "synonyms_path": "analysis/synonym.txt", "updateable": false }, "stemmer": { "type": "stemmer", "language": "english" }, "autocompleteFilter": { "max_shingle_size": "4", "min_shingle_size": "2", "type": "shingle" }, "stopwords": { "type": "stop", "stopwords": [ "_english_" ] } }, "analyzer": { "english_with_synonym": { "type": "custom", "tokenizer": "standard", "filter": [ "english_possessive_stemmer", "lowercase", "english_stop", "english_stemmer", "synonym" ] }, "wpsolr_analyser_did_you_mean": { "filter": [ "lowercase" ], "char_filter": [ "html_strip" ], "type": "custom", "tokenizer": "standard" }, "wpsolr_analyser_autocomplete": { "filter": [ "lowercase", "autocompleteFilter" ], "char_filter": [ "html_strip" ], "type": "custom", "tokenizer": "standard" }, "default": { "type": "english" }, "default_search": { "type": "english" } } } }, "mappings": { "dynamic_templates": [ { "text_en": { "match": "text", "mapping": { "type": "text" } } }, { "*_i": { "match": "*_i", "mapping": { "type": "long" } } }, { "*_s": { "match": "*_s", "mapping": { "type": "keyword" } } }, { "*_str": { "match": "*_str", "mapping": { "type": "keyword" } } }, { "*_l": { "match": "*_l", "mapping": { "type": "long" } } }, { "*_t": { "match": "*_t", "mapping": { "type": "text", "analyzer": "english_with_synonym" } } }, { "*_b": { "match": "*_b", "mapping": { "type": "boolean" } } }, { "*_f": { "match": "*_f", "mapping": { "type": "float" } } }, { "*_d": { "match": "*_d", "mapping": { "type": "double" } } }, { "*_dt": { "match": "*_dt", "mapping": { "type": "date" } } }, { "*_ll": { "match": "*_ll", "mapping": { "type": "geo_point" } } }, { "*_nobj": { "match": "*_nobj", "mapping": { "type": "nested" } } } ], "properties": { "id": { "type": "keyword" }, "PID": { "type": "keyword" }, "blogid": { "type": "keyword" }, "blogdomain": { "type": "keyword" }, "blogpath": { "type": "keyword" }, "wp": { "type": "keyword" }, "permalink": { "type": "keyword", "copy_to": [ "text" ] }, "title": { "type": "text", "analyzer": "english_with_synonym", "copy_to": [ "text", "spell", "autocomplete" ] }, "content": { "type": "text", "analyzer": "english_with_synonym", "copy_to": [ "text", "spell", "autocomplete" ] }, "numcomments": { "type": "integer" }, "comments": { "type": "text", "analyzer": "english_with_synonym" }, "categories": { "type": "text", "analyzer": "english_with_synonym", "copy_to": [ "text", "spell", "autocomplete" ] }, "categoriessrch": { "type": "text", "analyzer": "english_with_synonym" }, "tags": { "type": "keyword", "copy_to": [ "text", "spell", "autocomplete" ] }, "tagssrch": { "type": "text", "analyzer": "english_with_synonym" }, "author": { "type": "keyword" }, "type": { "type": "keyword" }, "date": { "type": "date" }, "modified": { "type": "date" }, "displaydate": { "type": "date" }, "displaymodified": { "type": "date" }, "spell": { "type": "text", "analyzer": "wpsolr_analyser_did_you_mean" }, "autocomplete": { "type": "completion", "contexts": [ { "name": "context_type", "type": "category", "path": "type" }, { "name": "context_blog_name", "type": "category", "path": "blog_name_str" } ] }, "text": { "type": "text", "analyzer": "english_with_synonym" } } } }3. Create your index in WPSOLR with the same index name my_new_index
4. Configure your index in WPSOLR
5. Index your data in WPSOLRwpsolrKeymaster3 years, 11 months ago in reply to: Boost Search on Taxonomy Pages #31397Relevancy means sorting by highest scoring. And scoring is internal to Elasticsearch, to match a query to a document, based on BM25.
There are ways to implement your own scoring, inside Elasticsearch, with Java Elasticsearch plugins or Painless scripting. But this is out of WPSOLR’s reach.
wpsolrKeymaster3 years, 11 months ago in reply to: Exact matches vs any word matches #31396This is a feature that the plugin does not provide, out of this support help.
wpsolrKeymaster3 years, 11 months ago in reply to: how to set word variations #31389The best way to do it with Elasticsearch is with synonyms files. But it’s not automatic, you’ll have to perform manual tasks (upload the file, and apply a command to reload it)
With Algolia, you can do it live on their UI.
With Weaviate, this is another level: search is based on meaning, and therefore is very resilient to any kind of mismatch between query and content.
wpsolrKeymaster3 years, 11 months ago in reply to: how to set word variations #31387No, it will not work. This documentation is related to a new index, not set with the WPSOLR’s index definitions.
You will have to create a new index from the command line, with a custom analyser including a synonyms filter.
Let me make some tests, and I’ll post here the command to execute.
wpsolrKeymaster3 years, 11 months ago in reply to: how to set word variations #31384schema.xml is for Solr indexes only.
There is nothing inside the plugin to push synonyms to Elasticsearch, because there is no API to do that.
(Algolia is the only search engine that provides a way to set synonyms from a dashboard UI)
wpsolrKeymaster3 years, 11 months ago in reply to: how to set word variations #31382The schema you showed me is a Solr schema, hence my answer related to Solr.
You can indeed follow /manage-elasticsearch-and-solr-analyser-configuration-files/ for Elasticsearch synonyms configuration.wpsolrKeymaster3 years, 11 months ago in reply to: Boost Search on Taxonomy Pages #31378Add:
use wpsolr\core\classes\ui\WPSOLR_Query;Or remove the WPSOLR_Query type in the function parameters.
wpsolrKeymaster3 years, 11 months ago in reply to: Boost Search on Taxonomy Pages #31376You can use an event for that:
add_filter( WPSOLR_Events::WPSOLR_FILTER_DEFAULT_SORT, 'wpsolr_filter_default_sort', 10, 2 ); /** * Apply specific default search on front * @param string $default_sort * @param WPSOLR_Query $wpsolr_query * @return string */ public function wpsolr_filter_default_sort( string $default_sort, WPSOLR_Query $wpsolr_query ) { return ($_GET['s'] === '') ? 'publication_date_str_desc' : WPSOLR_AbstractSearchClient::SORT_CODE_BY_RELEVANCY_DESC; }wpsolrKeymaster3 years, 11 months ago in reply to: how to set word variations #31374solr.SynonymFilterFactory is marked as deprecated. The synonym graph filter is to be used instead. You can find examples in the documentation link.
wpsolrKeymaster3 years, 11 months ago in reply to: how to set word variations #31372You should use the synonym graph filter
wpsolrKeymaster3 years, 11 months ago in reply to: Boost Search on Taxonomy Pages #31371How scoring is done is out of my reach, but all engines now use BM25.