0

I'm using solr 4-x (apachesolr) for search functionality in my Drupal 7 site. I'm using a token in some long text fields in some nodes of different content types across my site. Lets suppose the token is [token_name] and its value is "test". So, whenever I search "test", the nodes containing this token don't show in search results. But when I search [token_name], the concerned nodes show in the search results.

What is happening here is that instead of the original token value, the [token_name] is stored in database. So, for indexing, the [token_name] is getting indexed instead of its value. And hence, it is unable to show results related to "test" as search keyword. Is there anyway to do this? Please suggest as I need to fix this ASAP.

P.S. I can't replace [token_name] by its value while saving the node by hook_node_presave.

1 Answer 1

0

you can use hook_apachesolr_index_document_build() function to override node data index in apache solr

2
  • But how will I be able to replace all the tokens by their values? Because they aren't in a particular field of a particular content type. They can be anywhere. Commented Oct 10, 2017 at 6:25
  • u can use str_replace() function for this Commented Oct 10, 2017 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.