Reviewed & tested by the community
Project:
Elasticsearch Connector Autocomplete
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
5 Aug 2019 at 12:13 UTC
Updated:
4 Apr 2025 at 17:56 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
grimreaperHello,
Here is the patch.
I found the commit in elasticsearch_connector that introduces the change: https://git.drupalcode.org/project/elasticsearch_connector/commit/0f66b7...
Thanks for the review.
Comment #3
grimreaperAlso, I think a new branch will be required to match elasticsearch_connector branches.
Comment #4
a.dmitriiev commentedI confirm that patch is needed for elasticsearch_connector version 7.x. It doesn't use the 'type' as an array key.
Comment #5
bramdriesenI think there is another issue. The SearchApiDataType (text_ngram) is showing as none supported. Seems like the default = true flag needs to be added to elasticsearch_connector_autocomp/src/Plugin/search_api/data_type/TextNgramDataType.php like it's done in the elasticsearch_connector module.
Comment #6
bramdriesenNew patch attached with the change I was talking about.
Comment #7
mamoschli commentedHi,
I tried the last patch which solved the "not supported" issue but introduced a new one in combination with search_api_autocomplete. The search_api_autocomplete module queries the current search for fulltext fields to apply the autocomplete onto them. To retrieve the fulltext fields it uses the \Drupal\search_api\Entity\Index::getFulltextFields method which in turn uses the \Drupal\search_api\Utility\DataTypeHelper::isTextType function to determine if the current field is a text field.
You can see in the below code, that a field is only a text type if its type is "text" or it is not a default type and its fallback type is "text".
https://git.drupalcode.org/project/search_api/-/blob/8.x-1.x/src/Utility...
I think the reason for that behavior lies in the definition of the "default" property as stated in the comment here:
https://git.drupalcode.org/project/search_api/-/blob/8.x-1.x/src/Utility...
I found another hint for how this could work in the search_api field config which says:
So I think in this case the field type is special to the Elasticsearch engine and should therefore not be generally supported (as the default flag would indicate). Instead the server itself should declare its support for this type. However as far as I understand this is done inside the \Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend::supportsDataType function which checks against a static list of types (only object at the time of writing) without any possibilities to alter this.
I know that this is not an issue with this module, but I wanted to inform you that I think setting the default flag to true would not be the correct solution. I will possibly add an issue to the elasticsearch_connector module to see if this can be solved.
Comment #8
thursday_bw commentedChanging this to needs work. We need to decide on a viable solution and implement that.
I'm happy to receive a patch with a proposed resolution, any solution is better than none (generally)
Comment #9
jefuri commentedFixed it, just changing it to false (without quotes I might add) in the annotation is enough to make the ngram field useable again as text fallback from a views fulltext filter or argument.
Comment #10
jefuri commentedComment #11
bramdriesenTested and works for me :-)
Comment #12
Patrick Ryan commented#9 +RTBC - Looks good to me as long as we're not worried about being backward compatible with the older versions of Elasticsearch Connector. The ngram data type does still show as unsupported, but I'm not sure that this was supposed to resolve that.
Comment #13
zterry95 commentedThe patch works for me.

But the status on the data types still show warning.
Comment #14
alsantos123From https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis... I'm created a new patch to make this, wonderful, module work with Elasticsearch 7.13.x.
The original module really doesn't work because $params['type'] on elasticsearchConnectorPrepareIndexMapping() method (web/modules/contrib/elasticsearch_connector_autocomp/src/EventSubscriber/DefaultSubscriber.php:67).
The patch here helps to managed that issue, but the original module doesn't handle ngram as tokenizer (handle as filter) this has two implications:
PS: For who can't recreate the index, ElasticSearch has a query "query_string" that helps with this, eg:
this query will find: apple, rappi, whatsapp, etc
Follow the patch:
Comment #15
kevineinarsson commented#14 to patch for composer. I changed the annotation for TextNgramDataType like in #9 so fields indexed using this data type are returned by Index::getFulltextFields.
Comment #16
kevineinarsson commentedComment #17
p-neyens commentedFor a specific project the fulltext search needed to work with keyword "b2b". To make tis possible we needed to add the digit class to the token_chars setting. The previous patch only support the letter class. I extend the patch to make the token_chars and custom_ token_chars setting configurable.
Comment #18
marysmech commentedPatch #15 fixed all my issues after update from elastic 6.x.
Comment #19
dj1999 commentedCreated a patch which works with D 9.x Elastic 7 and php 8.1
Please review it.
Comment #20
dj1999 commentedLitle finetuning to #19
Comment #21
szato commentedUsing exposed filter (>=, <= operators) for date fields and got:
Error: Call to undefined method Drupal\search_api\Query\ConditionGroup::getField() in elasticsearch_connector_autocomp_elasticsearch_connector_search_api_query_alter()#20 patch modified.
Comment #22
nicrodgersThe patch needs updating to work with elasticsearch_connector 8.x-7.x.
PrepareIndexEvent::getIndex doesn't exist, it should be PrepareIndexEvent::getIndexName instead. There may be other changes needed. If I have time today I will see if I can update the patch.
Comment #23
bramdriesenComment #24
tvoesenek commentedFor one of our projects, we use the patch from #15, which worked fine. But due to deprecation of the boost-parameter, in combination with Elasticsearch 8, an error will occur:
When the boost-parameter is omitted, it works fine. Therefore I've rerolled the patch from #15, without the boost property.
So this is not a reroll of #21 and therefore this still needs work.
Comment #25
dmundraRe-rolling patch #24 for latest version of dev
Comment #26
msielskiWe have tested and are using the patch 3072676-25.patch from comment # 25.