BuildQuery() public static method

public static BuildQuery ( string query, IndexQuery indexQuery, Raven.Database.Indexing.RavenPerFieldAnalyzerWrapper analyzer ) : Query
query string
indexQuery Raven.Abstractions.Data.IndexQuery
analyzer Raven.Database.Indexing.RavenPerFieldAnalyzerWrapper
return Lucene.Net.Search.Query
Esempio n. 1
0
            private Query GetLuceneQuery(string query, string defaultField)
            {
                Query luceneQuery;

                if (String.IsNullOrEmpty(query))
                {
                    logQuerying.Debug("Issuing query on index {0} for all documents", parent.name);
                    luceneQuery = new MatchAllDocsQuery();
                }
                else
                {
                    logQuerying.Debug("Issuing query on index {0} for: {1}", parent.name, query);
                    var toDispose = new List <Action>();
                    PerFieldAnalyzerWrapper searchAnalyzer = null;
                    try
                    {
                        searchAnalyzer = parent.CreateAnalyzer(new LowerCaseKeywordAnalyzer(), toDispose, true);
                        searchAnalyzer = parent.AnalyzerGenerators.Aggregate(searchAnalyzer, (currentAnalyzer, generator) =>
                        {
                            Analyzer newAnalyzer = generator.GenerateAnalzyerForQuerying(parent.name, indexQuery.Query, currentAnalyzer);
                            if (newAnalyzer != currentAnalyzer)
                            {
                                DisposeAnalyzerAndFriends(toDispose, currentAnalyzer);
                            }
                            return(parent.CreateAnalyzer(newAnalyzer, toDispose, true));
                        });
                        luceneQuery = QueryBuilder.BuildQuery(query, defaultField, searchAnalyzer);
                    }
                    finally
                    {
                        DisposeAnalyzerAndFriends(toDispose, searchAnalyzer);
                    }
                }
                return(luceneQuery);
            }
Esempio n. 2
0
        private Query GetLuceneQuery(IndexQuery indexQuery)
        {
            var   query = indexQuery.Query;
            Query luceneQuery;

            if (string.IsNullOrEmpty(query))
            {
                log.DebugFormat("Issuing query on index {0} for all documents", name);
                luceneQuery = new MatchAllDocsQuery();
            }
            else
            {
                log.DebugFormat("Issuing query on index {0} for: {1}", name, query);
                var toDispose = new List <Action>();
                PerFieldAnalyzerWrapper analyzer = null;
                try
                {
                    analyzer = CreateAnalyzer(toDispose);

                    luceneQuery = QueryBuilder.BuildQuery(query, analyzer);
                }
                finally
                {
                    if (analyzer != null)
                    {
                        analyzer.Close();
                    }
                    foreach (var dispose in toDispose)
                    {
                        dispose();
                    }
                }
            }
            return(luceneQuery);
        }
Esempio n. 3
0
        public static HashSet <string> GetFields(IndexQuery query)
        {
            var hashSet = new HashSet <string>();

            if (string.IsNullOrWhiteSpace(query.Query))
            {
                return(hashSet);
            }
            var q = QueryBuilder.BuildQuery(query.Query, query, perFieldAnalyzerWrapper);

            PopulateFields(q, hashSet);
            hashSet.Remove(string.Empty);
            return(hashSet);
        }
Esempio n. 4
0
        private Query GetLuceneQuery(IndexQuery indexQuery)
        {
            var   query = indexQuery.Query;
            Query luceneQuery;

            if (string.IsNullOrEmpty(query))
            {
                log.DebugFormat("Issuing query on index {0} for all documents", name);
                luceneQuery = new MatchAllDocsQuery();
            }
            else
            {
                log.DebugFormat("Issuing query on index {0} for: {1}", name, query);
                luceneQuery = QueryBuilder.BuildQuery(query);
            }
            return(luceneQuery);
        }
Esempio n. 5
0
        private Query GetLuceneQuery(IndexQuery indexQuery)
        {
            var   query = indexQuery.Query;
            Query luceneQuery;

            if (string.IsNullOrEmpty(query))
            {
                logQuerying.DebugFormat("Issuing query on index {0} for all documents", name);
                luceneQuery = new MatchAllDocsQuery();
            }
            else
            {
                logQuerying.DebugFormat("Issuing query on index {0} for: {1}", name, query);
                var toDispose = new List <Action>();
                PerFieldAnalyzerWrapper analyzer = null;
                try
                {
                    analyzer = CreateAnalyzer(new LowerCaseAnalyzer(), toDispose);
                    analyzer = AnalyzerGenerators.Aggregate(analyzer, (currentAnalyzer, generator) =>
                    {
                        var newAnalyzer = generator.GenerateAnalzyerForQuerying(name, indexQuery.Query, currentAnalyzer);
                        if (newAnalyzer != currentAnalyzer)
                        {
                            DisposeAnalyzerAndFriends(toDispose, currentAnalyzer);
                        }
                        return(CreateAnalyzer(newAnalyzer, toDispose));;
                    });
                    luceneQuery = QueryBuilder.BuildQuery(query, analyzer);
                }
                finally
                {
                    DisposeAnalyzerAndFriends(toDispose, analyzer);
                }
            }
            return(luceneQuery);
        }