Skip to content

Commit bd71de0

Browse files
authored
Merge pull request #32493 from vespa-engine/revert-32491-bratseth/segment-on-index
Revert "Require positive proof of an index field to segment"
2 parents 5fd7a5d + b4db18b commit bd71de0

File tree

6 files changed

+12
-34
lines changed

6 files changed

+12
-34
lines changed

container-search/src/main/java/com/yahoo/prelude/query/ExactStringItem.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*
77
* @author baldersheim
88
*/
9+
910
public class ExactStringItem extends WordItem {
1011

1112
public ExactStringItem(String substring) {

container-search/src/main/java/com/yahoo/prelude/query/PhraseSegmentItem.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.Objects;
99
import java.util.Optional;
1010

11+
1112
/**
1213
* A term which contains a fixed length phrase, a collection of word terms,
1314
* resulting from a single segmentation operation.

container-search/src/main/java/com/yahoo/search/yql/YqlParser.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import com.yahoo.language.detect.Detector;
2626
import com.yahoo.language.process.Normalizer;
2727
import com.yahoo.language.process.Segmenter;
28-
import com.yahoo.prelude.Index;
2928
import com.yahoo.prelude.IndexFacts;
3029
import com.yahoo.prelude.Location;
3130
import com.yahoo.prelude.query.AndItem;
@@ -742,7 +741,7 @@ private Item instantiatePhraseSegmentItem(String field, OperatorNode<ExpressionO
742741
words = segmenter.segment(origin.getValue(), currentlyParsing.getLanguage());
743742
}
744743

745-
if (words != null && ! words.isEmpty()) {
744+
if (words != null && words.size() > 0) {
746745
for (String word : words) {
747746
phrase.addItem(new WordItem(word, field, true));
748747
}
@@ -1516,7 +1515,6 @@ private Item instantiateWordItem(String field,
15161515
boolean substrMatch = getAnnotation(ast, SUBSTRING, Boolean.class, Boolean.FALSE,
15171516
"setting for whether to use substring match of input data");
15181517
boolean exact = exactMatch != null ? exactMatch : indexFactsSession.getIndex(indexNameExpander.expand(field)).isExact();
1519-
15201518
String grammar = getAnnotation(ast, USER_INPUT_GRAMMAR, String.class,
15211519
Query.Type.WEAKAND.toString(), "grammar for handling word input");
15221520
Preconditions.checkArgument((prefixMatch ? 1 : 0) +
@@ -1560,7 +1558,7 @@ private Item instantiateWordItem(String field,
15601558
}
15611559

15621560
private boolean shouldSegment(String field, boolean fromQuery) {
1563-
return fromQuery && indexFactsSession.getIndex(indexNameExpander.expand(field)).isIndex();
1561+
return fromQuery && ! indexFactsSession.getIndex(indexNameExpander.expand(field)).isAttribute();
15641562
}
15651563

15661564
private TaggableItem segment(String field, OperatorNode<ExpressionOperator> ast, String wordData,

container-search/src/test/java/com/yahoo/prelude/querytransform/test/CJKSearcherTestCase.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import com.yahoo.component.chain.Chain;
55
import com.yahoo.language.Language;
66
import com.yahoo.language.Linguistics;
7-
import com.yahoo.prelude.*;
7+
import com.yahoo.prelude.IndexFacts;
8+
import com.yahoo.prelude.IndexFactsFactory;
89
import com.yahoo.prelude.query.Item;
910
import com.yahoo.prelude.query.NullItem;
1011
import com.yahoo.prelude.query.parser.TestLinguistics;
@@ -56,15 +57,8 @@ void testCjkQueryWithOverlappingTokens() {
5657

5758
@Test
5859
public void testEquivAndChinese() {
59-
SearchDefinition schema = new SearchDefinition("music-only");
60-
Index stringIndex = new Index("default");
61-
stringIndex.setIndex(true);
62-
stringIndex.setString(true);
63-
schema.addIndex(stringIndex);
64-
var indexFacts = new IndexFacts(new IndexModel(schema));
65-
6660
Query query = new Query(QueryTestCase.httpEncode("search?yql=select * from music-only where default contains equiv('a', 'b c') or default contains '东'"));
67-
new Execution(new Chain<>(new MinimalQueryInserter(), new CJKSearcher()), Execution.Context.createContextStub(indexFacts)).search(query);
61+
new Execution(new Chain<>(new MinimalQueryInserter(), new CJKSearcher()), Execution.Context.createContextStub()).search(query);
6862
assertEquals("OR (EQUIV default:a default:'b c') default:东", query.getModel().getQueryTree().toString());
6963
}
7064

container-search/src/test/java/com/yahoo/search/yql/MinimalQueryInserterTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void testUserLanguageIsDetectedWithUserQueryEnglishAlsoWithNonEnglishStructuredQ
185185
Result result = execution.search(query);
186186
assertNull(result.hits().getError());
187187
assertEquals(Language.ENGLISH, query.getModel().getParsingLanguage()); // by UNKNOWN -> ENGLISH
188-
assertEquals("AND attribute_key:我能吞下玻璃而不伤身体 (WEAKAND(100) executions)", query.getModel().getQueryTree().toString());
188+
assertEquals("AND attribute_key:我能吞下玻璃而不伤身体 (WEAKAND(100) executions)", query.getModel().getQueryTree().toString());
189189
}
190190

191191
@Test
@@ -195,7 +195,7 @@ void testUserLanguageIsDetectedWithUserInputEnglishAlsoWithNonEnglishStructuredQ
195195
Result result = execution.search(query);
196196
assertNull(result.hits().getError());
197197
assertEquals(Language.ENGLISH, query.getModel().getParsingLanguage()); // by UNKNOWN -> ENGLISH
198-
assertEquals("AND attribute_key:我能吞下玻璃而不伤身体 (WEAKAND(100) default:executions)", query.getModel().getQueryTree().toString());
198+
assertEquals("AND attribute_key:我能吞下玻璃而不伤身体 (WEAKAND(100) default:executions)", query.getModel().getQueryTree().toString());
199199
}
200200

201201
@Test

0 commit comments

Comments
 (0)