1

I'm running Drupal core 10.2.1, Search API Solr 4.3.1, and Solr server 9.4.0. I've noticed that some searches aren't finding indexed content and I'm wondering if the field type definition is correct. The data types can be set at /admin/config/search/search-api/index/myindex/fields.

The field in question is a string that includes hyphens, such as "2B257-Kit-1". A search for "2B257" will find content, but searches for "2B257-Kit" and "2B257-Kit-1" return no results. I've tried multiple data types without success. How can I match these values to return appropriate search results?

1
  • I’m not an expert but this may have more to do with the solr core configuration (maybe stemming?) than than with Drupal. But take this with a grain of salt.
    – cilefen
    Jan 17 at 22:25

2 Answers 2

1

This seems relevant and could be the cause of your issue: Products containing a hyphen or numbers not shown or wrong relevance

In my experience we have needed to use the type "Fulltext ngram" for partial matching. Make sure you are reindexing your content after each field type change as well.

8
  • Thanks for the suggestion. I made that change, reindexed, and tried the search again. Same result, no match. I should mention that I'm also using Search API Views, and the filter criteria could be the issue. Again, though, I've tried multiple settings for the parse mode and haven't yet found a solution. Jan 18 at 23:01
  • This feels like a Solr config issue. What kind of logging can you enable / access in order to debug this further? I would setup a dummy content type, with one node, and a search index devoted to it. Isolate the problem in that one place and review logs. Alternatively you might add some debug / breakpoints to the search api code but not sure that would get you visibility into what Solr processing. I don't have a lot of Solr logging experience but that would be my next step. Jan 19 at 12:50
  • I can use the solr admin web interface to analyze queries, but I'm not familiar enough with it to really understand what I'm seeing. It does appear, however, that solr searches are matching. This makes me think that the issue is with the filter settings available in this view, where it doesn't appear that substring matching is an available setting. Jan 22 at 14:30
  • Can you implement one of these hooks to see if the result you expect is included and can be "forced" into the result set? api.druphelp.com/api/search_api_solr/search_api_solr.api.php/… Jan 23 at 17:42
  • Possibly. It looks like hook_search_api_solr_search_results_alter would be the right hook to experiment with. Jan 23 at 21:09
0

I found a working combination of settings: after setting the Search API Solr field type to "fulltext ngramstring" and the views fulltext search parse mode in the views filter to "multiple words" I'm able to return results for a substring-matching query as described above.

1
  • Glad you got this working! Jan 30 at 20:55

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.