-
Type: Bug
-
Status: Resolved
-
Priority: Minor
-
Resolution: Fixed
-
Affects Version/s: None
-
Component/s: Core MongoDB, Tests
-
Epic Link:
-
Tags:
-
Sprint:nxFG 8.2.1, nxFG 8.2.2
-
Story Points:3
The test ITDocumentRelationTest.testSimpleRelationBetweenTwoDocuments fails on MongoDB with:
java.lang.IllegalArgumentException: More suggestions than expected for s2id_createForm:nxw_singleDocumentSuggestion_2_select2 at org.nuxeo.functionaltests.forms.Select2WidgetElement.selectValue(Select2WidgetElement.java:230) at org.nuxeo.functionaltests.forms.Select2WidgetElement.selectValue(Select2WidgetElement.java:196) at org.nuxeo.functionaltests.pages.tabs.RelationTabSubPage.setRelationWithDocument(RelationTabSubPage.java:134) at org.nuxeo.ftest.cap.ITDocumentRelationTest.testSimpleRelationBetweenTwoDocuments(ITDocumentRelationTest.java:98)
What happens is that at the step when we typed "Fil" then it does a search of ecm:fulltext LIKE 'fil%' (from page provider default_document_suggestion) which is translated in MongoDB as a query on
{ "$text" : { "$search" : "fil*" }}
However MongoDB text search doesn't understand prefix search, it only matches exact words (modulo stemming).
So this search returns 0 result, but then on typing the next character we have "File" and this matches the fulltext. So the number of results increase while we type, which the test doesn't expect.
As there is no way to do prefix-search on the fulltext for MongoDB, the simplest fix is to pass this page provider (default_document_suggestion, not to be confused with DEFAULT_DOCUMENT_SUGGESTION used by the suggestbox addon) to Elasticsearch.