public PhraseWeight(PhraseQuery enclosingInstance, Searcher searcher) { InitBlock(enclosingInstance); this.searcher = searcher; }
private void InitBlock(PhraseQuery enclosingInstance) { this.enclosingInstance = enclosingInstance; }
/// <exception cref=""> ParseException throw in overridden method to disallow /// </exception> protected internal virtual Query GetFieldQuery(System.String field, System.String queryText) { // Use the analyzer to get all the tokens, and then build a TermQuery, // PhraseQuery, or nothing based on the term count TokenStream source = analyzer.TokenStream(field, new System.IO.StringReader(queryText)); System.Collections.ArrayList v = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); Monodoc.Lucene.Net.Analysis.Token t; while (true) { try { t = source.Next(); } catch (System.IO.IOException e) { t = null; } if (t == null) break; v.Add(t.TermText()); } try { source.Close(); } catch (System.IO.IOException e) { // ignore } if (v.Count == 0) return null; else if (v.Count == 1) return new TermQuery(new Term(field, (System.String) v[0])); else { PhraseQuery q = new PhraseQuery(); q.SetSlop(phraseSlop); for (int i = 0; i < v.Count; i++) { q.Add(new Term(field, (System.String) v[i])); } return q; } }