lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [lucenenet] 37/42: BUG: Lucene.Net.Highlighter.VectorHighlight.FieldQuery: List<T> replacement for LinkedHashSet<T> preserves insertion order, but we need to explicitly check to ensure no duplicate values are added
Date Wed, 07 Aug 2019 22:26:34 GMT
This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git

commit 0245279c420bef7e14be4e3cb241726cbb180dab
Author: Shad Storhaug <shad@shadstorhaug.com>
AuthorDate: Wed Aug 7 08:43:45 2019 +0700

    BUG: Lucene.Net.Highlighter.VectorHighlight.FieldQuery: List<T> replacement for
LinkedHashSet<T> preserves insertion order, but we need to explicitly check to ensure
no duplicate values are added
---
 .../VectorHighlight/FieldQuery.cs                   | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/Lucene.Net.Highlighter/VectorHighlight/FieldQuery.cs b/src/Lucene.Net.Highlighter/VectorHighlight/FieldQuery.cs
index 369c4b7..8c2676b 100644
--- a/src/Lucene.Net.Highlighter/VectorHighlight/FieldQuery.cs
+++ b/src/Lucene.Net.Highlighter/VectorHighlight/FieldQuery.cs
@@ -110,7 +110,7 @@ namespace Lucene.Net.Search.VectorHighlight
             }
             else if (sourceQuery is PhraseQuery)
             {
-                if (!flatQueries.Contains(sourceQuery))
+                if (!flatQueries.Contains(sourceQuery)) // LUCENENET - set semantics, but
this is a list. The original logic was already correct.
                 {
                     PhraseQuery pq = (PhraseQuery)sourceQuery;
                     if (pq.GetTerms().Length > 1)
@@ -119,7 +119,8 @@ namespace Lucene.Net.Search.VectorHighlight
                     {
                         Query flat = new TermQuery(pq.GetTerms()[0]);
                         flat.Boost = pq.Boost;
-                        flatQueries.Add(flat);
+                        if (!flatQueries.Contains(flat)) // LUCENENET specific - set semantics,
but this is a list
+                            flatQueries.Add(flat);
                     }
                 }
             }
@@ -202,13 +203,17 @@ namespace Lucene.Net.Search.VectorHighlight
                 {
                     i++;
                 }
-                expandQueries.Add(query);
+                if (!expandQueries.Contains(query)) // LUCENENET specific - set semantics,
but this is a list
+                    expandQueries.Add(query);
                 if (!(query is PhraseQuery)) continue;
-                for (IEnumerator<Query> j = flatQueries.GetEnumerator(); j.MoveNext();)
+                using (IEnumerator<Query> j = flatQueries.GetEnumerator())
                 {
-                    Query qj = j.Current;
-                    if (!(qj is PhraseQuery)) continue;
-                    CheckOverlap(expandQueries, (PhraseQuery)query, (PhraseQuery)qj);
+                    while (j.MoveNext())
+                    {
+                        Query qj = j.Current;
+                        if (!(qj is PhraseQuery)) continue;
+                        CheckOverlap(expandQueries, (PhraseQuery)query, (PhraseQuery)qj);
+                    }
                 }
             }
 
@@ -289,7 +294,7 @@ namespace Lucene.Net.Search.VectorHighlight
                     }
                     pq.Slop = slop;
                     pq.Boost = boost;
-                    if (!expandQueries.Contains(pq))
+                    if (!expandQueries.Contains(pq)) // LUCENENET specific - set semantics,
but this is a list
                         expandQueries.Add(pq);
                 }
             }


Mime
View raw message