public override System.Object Clone() { int sz = clauses.Count; SpanQuery[] newClauses = new SpanQuery[sz]; for (int i = 0; i < sz; i++) { SpanQuery clause = (SpanQuery) clauses[i]; newClauses[i] = (SpanQuery) clause.Clone(); } PayloadNearQuery boostingNearQuery = new PayloadNearQuery(newClauses, slop, inOrder); boostingNearQuery.SetBoost(GetBoost()); return boostingNearQuery; }
public override System.Object Clone() { int sz = clauses.Count; SpanQuery[] newClauses = new SpanQuery[sz]; for (int i = 0; i < sz; i++) { SpanQuery clause = (SpanQuery)clauses[i]; newClauses[i] = (SpanQuery)clause.Clone(); } PayloadNearQuery boostingNearQuery = new PayloadNearQuery(newClauses, slop, inOrder); boostingNearQuery.SetBoost(GetBoost()); return(boostingNearQuery); }
private void GetPayloads(ICollection <byte[]> payloads, SpanQuery query) { Mono.Lucene.Net.Search.Spans.Spans spans = query.GetSpans(reader); while (spans.Next() == true) { if (spans.IsPayloadAvailable()) { //ICollection<byte[]> payload = spans.GetPayload(); System.Collections.Generic.ICollection <byte[]> payload = spans.GetPayload(); //IEnumerator<byte[]> it = payload.GetEnumerator(); foreach (byte[] bytes in payload) { payloads.Add(bytes); } } } }
public override System.String ToString(System.String field) { System.Text.StringBuilder buffer = new System.Text.StringBuilder(); buffer.Append("payloadNear(["); System.Collections.IEnumerator i = clauses.GetEnumerator(); while (i.MoveNext()) { SpanQuery clause = (SpanQuery)i.Current; buffer.Append(clause.ToString(field)); if (i.MoveNext()) { buffer.Append(", "); } } buffer.Append("], "); buffer.Append(slop); buffer.Append(", "); buffer.Append(inOrder); buffer.Append(")"); buffer.Append(ToStringUtils.Boost(GetBoost())); return(buffer.ToString()); }
private void QueryToSpanQuery(Query query, ICollection<byte[]> payloads) { if (query is BooleanQuery) { BooleanClause[] queryClauses = ((BooleanQuery) query).GetClauses(); for (int i = 0; i < queryClauses.Length; i++) { if (!queryClauses[i].IsProhibited()) { QueryToSpanQuery(queryClauses[i].GetQuery(), payloads); } } } else if (query is PhraseQuery) { Term[] phraseQueryTerms = ((PhraseQuery) query).GetTerms(); SpanQuery[] clauses = new SpanQuery[phraseQueryTerms.Length]; for (int i = 0; i < phraseQueryTerms.Length; i++) { clauses[i] = new SpanTermQuery(phraseQueryTerms[i]); } int slop = ((PhraseQuery) query).GetSlop(); bool inorder = false; if (slop == 0) { inorder = true; } SpanNearQuery sp = new SpanNearQuery(clauses, slop, inorder); sp.SetBoost(query.GetBoost()); GetPayloads(payloads, sp); } else if (query is TermQuery) { SpanTermQuery stq = new SpanTermQuery(((TermQuery) query).GetTerm()); stq.SetBoost(query.GetBoost()); GetPayloads(payloads, stq); } else if (query is SpanQuery) { GetPayloads(payloads, (SpanQuery) query); } else if (query is FilteredQuery) { QueryToSpanQuery(((FilteredQuery) query).GetQuery(), payloads); } else if (query is DisjunctionMaxQuery) { for (System.Collections.IEnumerator iterator = ((DisjunctionMaxQuery) query).Iterator(); iterator.MoveNext(); ) { QueryToSpanQuery((Query) iterator.Current, payloads); } } else if (query is MultiPhraseQuery) { MultiPhraseQuery mpq = (MultiPhraseQuery) query; System.Collections.IList termArrays = mpq.GetTermArrays(); int[] positions = mpq.GetPositions(); if (positions.Length > 0) { int maxPosition = positions[positions.Length - 1]; for (int i = 0; i < positions.Length - 1; ++i) { if (positions[i] > maxPosition) { maxPosition = positions[i]; } } System.Collections.ArrayList[] disjunctLists = new System.Collections.ArrayList[maxPosition + 1]; int distinctPositions = 0; for (int i = 0; i < termArrays.Count; ++i) { Term[] termArray = (Term[]) termArrays[i]; System.Collections.IList disjuncts = disjunctLists[positions[i]]; if (disjuncts == null) { disjuncts = (disjunctLists[positions[i]] = new System.Collections.ArrayList(termArray.Length)); ++distinctPositions; } for (int j = 0; j < termArray.Length; ++j) { disjuncts.Add(new SpanTermQuery(termArray[j])); } } int positionGaps = 0; int position = 0; SpanQuery[] clauses = new SpanQuery[distinctPositions]; for (int i = 0; i < disjunctLists.Length; ++i) { System.Collections.ArrayList disjuncts = disjunctLists[i]; if (disjuncts != null) { clauses[position++] = new SpanOrQuery((SpanQuery[]) (disjuncts.ToArray(typeof(SpanQuery[])))); } else { ++positionGaps; } } int slop = mpq.GetSlop(); bool inorder = (slop == 0); SpanNearQuery sp = new SpanNearQuery(clauses, slop + positionGaps, inorder); sp.SetBoost(query.GetBoost()); GetPayloads(payloads, sp); } } }
private void GetPayloads(ICollection<byte[]> payloads, SpanQuery query) { Mono.Lucene.Net.Search.Spans.Spans spans = query.GetSpans(reader); while (spans.Next() == true) { if (spans.IsPayloadAvailable()) { //ICollection<byte[]> payload = spans.GetPayload(); System.Collections.Generic.ICollection<byte[]> payload = spans.GetPayload(); //IEnumerator<byte[]> it = payload.GetEnumerator(); foreach (byte[] bytes in payload) { payloads.Add(bytes); } } } }
public PayloadNearSpanWeight(PayloadNearQuery enclosingInstance, SpanQuery query, Searcher searcher) : base(query, searcher) { InitBlock(enclosingInstance); }
private void QueryToSpanQuery(Query query, ICollection <byte[]> payloads) { if (query is BooleanQuery) { BooleanClause[] queryClauses = ((BooleanQuery)query).GetClauses(); for (int i = 0; i < queryClauses.Length; i++) { if (!queryClauses[i].IsProhibited()) { QueryToSpanQuery(queryClauses[i].GetQuery(), payloads); } } } else if (query is PhraseQuery) { Term[] phraseQueryTerms = ((PhraseQuery)query).GetTerms(); SpanQuery[] clauses = new SpanQuery[phraseQueryTerms.Length]; for (int i = 0; i < phraseQueryTerms.Length; i++) { clauses[i] = new SpanTermQuery(phraseQueryTerms[i]); } int slop = ((PhraseQuery)query).GetSlop(); bool inorder = false; if (slop == 0) { inorder = true; } SpanNearQuery sp = new SpanNearQuery(clauses, slop, inorder); sp.SetBoost(query.GetBoost()); GetPayloads(payloads, sp); } else if (query is TermQuery) { SpanTermQuery stq = new SpanTermQuery(((TermQuery)query).GetTerm()); stq.SetBoost(query.GetBoost()); GetPayloads(payloads, stq); } else if (query is SpanQuery) { GetPayloads(payloads, (SpanQuery)query); } else if (query is FilteredQuery) { QueryToSpanQuery(((FilteredQuery)query).GetQuery(), payloads); } else if (query is DisjunctionMaxQuery) { for (System.Collections.IEnumerator iterator = ((DisjunctionMaxQuery)query).Iterator(); iterator.MoveNext();) { QueryToSpanQuery((Query)iterator.Current, payloads); } } else if (query is MultiPhraseQuery) { MultiPhraseQuery mpq = (MultiPhraseQuery)query; System.Collections.IList termArrays = mpq.GetTermArrays(); int[] positions = mpq.GetPositions(); if (positions.Length > 0) { int maxPosition = positions[positions.Length - 1]; for (int i = 0; i < positions.Length - 1; ++i) { if (positions[i] > maxPosition) { maxPosition = positions[i]; } } System.Collections.ArrayList[] disjunctLists = new System.Collections.ArrayList[maxPosition + 1]; int distinctPositions = 0; for (int i = 0; i < termArrays.Count; ++i) { Term[] termArray = (Term[])termArrays[i]; System.Collections.IList disjuncts = disjunctLists[positions[i]]; if (disjuncts == null) { disjuncts = (disjunctLists[positions[i]] = new System.Collections.ArrayList(termArray.Length)); ++distinctPositions; } for (int j = 0; j < termArray.Length; ++j) { disjuncts.Add(new SpanTermQuery(termArray[j])); } } int positionGaps = 0; int position = 0; SpanQuery[] clauses = new SpanQuery[distinctPositions]; for (int i = 0; i < disjunctLists.Length; ++i) { System.Collections.ArrayList disjuncts = disjunctLists[i]; if (disjuncts != null) { clauses[position++] = new SpanOrQuery((SpanQuery[])(disjuncts.ToArray(typeof(SpanQuery[])))); } else { ++positionGaps; } } int slop = mpq.GetSlop(); bool inorder = (slop == 0); SpanNearQuery sp = new SpanNearQuery(clauses, slop + positionGaps, inorder); sp.SetBoost(query.GetBoost()); GetPayloads(payloads, sp); } } }
public PayloadNearQuery(SpanQuery[] clauses, int slop, bool inOrder, PayloadFunction function):base(clauses, slop, inOrder) { fieldName = clauses[0].GetField(); // all clauses must have same field this.function = function; }
public PayloadNearQuery(SpanQuery[] clauses, int slop, bool inOrder):this(clauses, slop, inOrder, new AveragePayloadFunction()) { }
public PayloadNearSpanWeight(PayloadNearQuery enclosingInstance, SpanQuery query, Searcher searcher):base(query, searcher) { InitBlock(enclosingInstance); }
/// <summary>Constructs a filter which only matches documents matching /// <code>query</code>. /// </summary> /// <param name="query">The {@link Mono.Lucene.Net.Search.Spans.SpanQuery} to use as the basis for the Filter. /// </param> public SpanQueryFilter(SpanQuery query) { this.query = query; }
/// <summary>Constructs a filter which only matches documents matching /// <code>query</code>. /// </summary> /// <param name="query">The {@link Mono.Lucene.Net.Search.Spans.SpanQuery} to use as the basis for the Filter. /// </param> public SpanQueryFilter(SpanQuery query) { this.query = query; }