Search by word parts in Drupal 8 with Solr 5
I have installed:
- Drupal 8
- Solr 5
- search_api_solr (version: 8.x-1.4) module.
It was configured and working well but I have one big issue. The search didn’t work by patrials of words.
The short solution:
in search_api_solr/solr-conf/5.x/schema.xml to replace
<filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="25" />
to
<filter class=”solr.NGramFilterFactory” minGramSize=”2" maxGramSize=”25" />
More details
The search worked by Title field so I went to
/admin/config/search/search-api/index/lexis_solr_index/fields
to check the Type of index for the title field. I found there Full text


I found this:
Fulltext fields are analyzed fields which are made available for fulltext search. This data type should be used for any fields (usually with free text input by users) which you want to search for individual words.
An individual words but I want search by parts of words.
After searching I found that the Fulltext Ngram should search by parts of words. I selected that and reindex the content.
It started to work but not well. The hippopotamus word was searched by ‘hi’, ‘hip’, ‘hipp’, ‘hippo’, ‘hippop’ etc.
I found the reason in this issue
https://www.drupal.org/project/search_api_solr/issues/3022896
For Fulltext Ngram was used EdgeNGramFilterFactory
There you can read how it works: Edge N-Gram Tokenizer
http://archive.apache.org/dist/lucene/solr/ref-guide/apache-solr-ref-guide-5.3.pdf#page=96&zoom=auto,-187,297
And there I found that I wanted: N-Gram Filter
http://archive.apache.org/dist/lucene/solr/ref-guide/apache-solr-ref-guide-5.3.pdf#page=112&zoom=auto,-187,475
So I went to
search_api_solr/solr-conf/5.x/schema.xml
found the edge_n2_kw_text it was used for Fulltext Ngram.
And replaced
<filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="25" />
to
<filter class=”solr.NGramFilterFactory” minGramSize=”2" maxGramSize=”25" />
The result schema.xml
That’s all. In last versions of search_api_solr the issue is fixed.