public virtual void TestToString() { PhraseQuery q = new PhraseQuery(); // Query "this hi this is a test is" q.Add(new Term("field", "hi"), 1); q.Add(new Term("field", "test"), 5); Assert.AreEqual(q.ToString(), "field:\"? hi ? ? ? test\""); q.Add(new Term("field", "hello"), 1); Assert.AreEqual(q.ToString(), "field:\"? hi|hello ? ? ? test\""); }
public virtual void TestToString() { StopAnalyzer analyzer = new StopAnalyzer(Util.Version.LUCENE_CURRENT); QueryParser qp = new QueryParser(Util.Version.LUCENE_CURRENT, "field", analyzer); qp.EnablePositionIncrements = true; PhraseQuery q = (PhraseQuery)qp.Parse("\"this hi this is a test is\""); Assert.AreEqual("field:\"? hi ? ? ? test\"", q.ToString()); q.Add(new Term("field", "hello"), 1); Assert.AreEqual("field:\"? hi|hello ? ? ? test\"", q.ToString()); }
public virtual void TestToString() { StopAnalyzer analyzer = new StopAnalyzer(); StopFilter.SetEnablePositionIncrementsDefault(true); QueryParser qp = new QueryParser("field", analyzer); qp.SetEnablePositionIncrements(true); PhraseQuery q = (PhraseQuery)qp.Parse("\"this hi this is a test is\""); Assert.AreEqual("field:\"? hi ? ? ? test\"", q.ToString()); q.Add(new Term("field", "hello"), 1); Assert.AreEqual("field:\"? hi|hello ? ? ? test\"", q.ToString()); }
public string GetSearchQuery(params ISearchableMetadataValue[] searchableMetadataValues) { var query = new PhraseQuery(); foreach (var searchableMetadataValue in searchableMetadataValues) { query.Add(new Term(searchableMetadataValue.Metadata.SearchName, searchableMetadataValue.Value)); } var filter = query.ToString(); return GetSearchQuery(filter, new SearchableMetadata[] { }); }