Esempio n. 1
0
        internal FieldQuery(Query query, IndexReader reader, bool phraseHighlight, bool fieldMatch)
        {
            this.fieldMatch = fieldMatch;
            // LUCENENET NOTE: LinkedHashSet cares about insertion order
            ISet <Query> flatQueries = new JCG.LinkedHashSet <Query>();

            Flatten(query, reader, flatQueries);
            SaveTerms(flatQueries, reader);
            ICollection <Query> expandQueries = Expand(flatQueries);

            foreach (Query flatQuery in expandQueries)
            {
                QueryPhraseMap rootMap = GetRootMap(flatQuery);
                rootMap.Add(flatQuery /*, reader // LUCENENET: Never read */);
                if (!phraseHighlight && flatQuery is PhraseQuery pq)
                {
                    if (pq.GetTerms().Length > 1)
                    {
                        foreach (Term term in pq.GetTerms())
                        {
                            rootMap.AddTerm(term, flatQuery.Boost);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        int termOrPhraseNumber; // used for colored tag support

        public FieldQuery(Query query, bool phraseHighlight, bool fieldMatch)
        {
            this.fieldMatch = fieldMatch;
            Dictionary <Query, Query> flatQueries = new Dictionary <Query, Query>();

            flatten(query, flatQueries);
            SaveTerms(flatQueries);
            Dictionary <Query, Query> expandQueries = expand(flatQueries);

            foreach (Query flatQuery in expandQueries.Keys)
            {
                QueryPhraseMap rootMap = getRootMap(flatQuery);
                rootMap.Add(flatQuery);
                if (!phraseHighlight && flatQuery is PhraseQuery)
                {
                    PhraseQuery pq = (PhraseQuery)flatQuery;
                    if (pq.GetTerms().Length > 1)
                    {
                        foreach (Term term in pq.GetTerms())
                        {
                            rootMap.AddTerm(term.Text, flatQuery.Boost);
                        }
                    }
                }
            }
        }