Excerpt of results not show
-
wpsolrKeymaster3 years ago #35617
You can use a hook to modify the results, including title and content: WPSOLR_Events::WPSOLR_ACTION_BEFORE_RENDER_TEMPLATE
use wpsolr\core\classes\WPSOLR_Events; add_filter( WPSOLR_Events::WPSOLR_ACTION_BEFORE_RENDER_TEMPLATE, 'wpsolr_action_before_render_template', 10, 1 ); /** * @param array $template_params * * @return array */ public function wpsolr_action_before_render_template( $template_params ) { foreach ( $template_params['template_data']['results']['items'] as &$result ) { // Modify $result if title or content are empty if ('...' === $result['content']) { // Replace with original post excerpt from get_post($result['PID']) } } return $template_params; }You can find a full example in /plugins/wpsolr-pro/wpsolr-pro/wpsolr/pro/extensions/woocommerce/class-wpsolr-plugin-woocommerce.php
matteo.cattelanParticipant3 years ago #35618ok I think I understand, thank you very much, is there a hook also for the “did you mean” in the case of poorly written search text?
matteo.cattelanParticipant3 years ago #35624If i active the option in Wpsolr backend in wordpress i have this error:
{“error”:{“root_cause”:[{“type”:”illegal_argument_exception”,”reason”:”no mapping found for field [spell]”}],”type”:”search_phase_execution_exception”,”reason”:”all shards failed”,”phase”:”query”,”grouped”:true,”failed_shards”:[{“shard”:0,”index”:”wp_it”,”node”:”GbLND5ZMSrqT3nD1giH9Ew”,”reason”:{“type”:”illegal_argument_exception”,”reason”:”no mapping found for field [spell]”}}],”caused_by”:{“type”:”illegal_argument_exception”,”reason”:”no mapping found for field [spell]”,”caused_by”:{“type”:”illegal_argument_exception”,”reason”:”no mapping found for field [spell]”}}},”status”:400}Do I need to configure something?
Thanks a lot- This reply was modified 3 years ago by matteo.cattelan.
matteo.cattelanParticipant3 years ago #35628ok, this issue is closed for me, thanks a lot for all.
matteo.cattelanParticipant3 years ago #35650thank you very much for the clarification, too kind but I have already solved it with the hook solution.
Thanks
wpsolrKeymaster3 years ago #35651You’ll get even more control with the hook.
By the way, did you consider using our neural search with Weaviate? Looks natural considering the AI nature of your site content!
Some Open source Sentence Transformers models are multilingual, and vector search can scale to billions of vectors easily and cheaply.
(their real cost is for indexing/vectorizing data where GPUs are required on large scale).- This reply was modified 3 years ago by wpsolr.
You must be logged in to reply to this topic.