diff options
author | Jon Bratseth <bratseth@gmail.com> | 2022-08-16 12:58:33 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2022-08-16 12:58:33 +0200 |
commit | 6cc84e06d7d24e68c83ba5a3550e64d9fb917096 (patch) | |
tree | c5fad27f6aa64791d1379181d6ceb063fc855d75 /container-search/src/test/java/com | |
parent | cf579cd8d957b1bb2992d7a86830fbca3a64f82b (diff) |
Revert "Merge pull request #23669 from vespa-engine/revert-23581-userinput-does-not-use-defaultIndex-while-resolving-indexableitem"
This reverts commit d8a38777428495670078d23cd86863829ca8018d, reversing
changes made to aa89c25d0ed2e8b0390ef62c6e55feecdd4c7815.
Diffstat (limited to 'container-search/src/test/java/com')
-rw-r--r-- | container-search/src/test/java/com/yahoo/search/yql/UserInputTestCase.java | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/container-search/src/test/java/com/yahoo/search/yql/UserInputTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/UserInputTestCase.java index 8fe451dd095..1e3b52c23af 100644 --- a/container-search/src/test/java/com/yahoo/search/yql/UserInputTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/yql/UserInputTestCase.java @@ -3,7 +3,10 @@ package com.yahoo.search.yql; import static org.junit.jupiter.api.Assertions.*; -import com.yahoo.search.query.QueryTree; +import com.yahoo.prelude.Index; +import com.yahoo.prelude.IndexFacts; +import com.yahoo.prelude.IndexModel; +import com.yahoo.prelude.SearchDefinition; import org.apache.http.client.utils.URIBuilder; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -367,4 +370,32 @@ public class UserInputTestCase { assertEquals("select * from sources * where text_field contains \"boom\"", query.yqlRepresentation()); } + @Test + void testUserInputWithPhraseSegmentingIndex() { + execution = new Execution(searchChain, Execution.Context.createContextStub(createIndexFacts(true))); + URIBuilder builder = searchUri(); + builder.setParameter("wql", "foo&bar"); + builder.setParameter("yql", "select * from sources * where ([{\"defaultIndex\": \"text_field\",\"grammar\": \"any\"}]userInput(@wql))"); + Query query = searchAndAssertNoErrors(builder); + assertEquals("select * from sources * where text_field contains phrase(\"foo\", \"bar\")", query.yqlRepresentation()); + } + + @Test + void testUserInputWithNonPhraseSegmentingIndex() { + execution = new Execution(searchChain, Execution.Context.createContextStub(createIndexFacts(false))); + URIBuilder builder = searchUri(); + builder.setParameter("wql", "foo&bar"); + builder.setParameter("yql", "select * from sources * where ([{\"defaultIndex\": \"text_field\",\"grammar\": \"any\"}]userInput(@wql))"); + Query query = searchAndAssertNoErrors(builder); + assertEquals("select * from sources * where (text_field contains \"foo\" AND text_field contains \"bar\")", query.yqlRepresentation()); + } + + private IndexFacts createIndexFacts(boolean phraseSegmenting) { + SearchDefinition sd = new SearchDefinition("sources"); + Index test = new Index("text_field"); + test.setPhraseSegmenting(phraseSegmenting); + sd.addIndex(test); + return new IndexFacts(new IndexModel(sd)); + } + } |