public static Query ParseQuery(string searchQuery, string defaultFieldName)
        {
            var   parser = new QueryParser(Version.LUCENE_30, defaultFieldName, JsonMappingUtils.GetAnalyser());
            Query query;

            try
            {
                if (String.IsNullOrEmpty(searchQuery))
                {
                    query = new MatchAllDocsQuery();
                }
                else
                {
                    query = parser.Parse(searchQuery.Trim());
                }
            }
            catch (ParseException)
            {
                query = parser.Parse(QueryParser.Escape(searchQuery.Trim()));
            }
            return(query);
        }
Exemple #2
0
        public static Query ParseQuery(string searchQuery, string defaultFieldName, string CultureCode = "")
        {
            searchQuery = RemoveDiacritics(searchQuery);
            searchQuery = searchQuery.Replace('-', ' '); // concider '-' as a space
            var   parser = new QueryParser(Version.LUCENE_30, defaultFieldName, JsonMappingUtils.GetAnalyser(CultureCode));
            Query query;

            try
            {
                if (string.IsNullOrEmpty(searchQuery))
                {
                    query = _DefaultQuery;
                }
                else
                {
                    query = parser.Parse(searchQuery.Trim());
                }
            }
            catch (ParseException)
            {
                query = searchQuery != null?parser.Parse(QueryParser.Escape(searchQuery.Trim())) : _DefaultQuery;
            }
            return(query);
        }
 private LuceneController()
 {
     _serviceInstance = new LuceneService(AppConfig.Instance.LuceneIndexFolder, JsonMappingUtils.GetAnalyser());
 }
Exemple #4
0
        private LuceneController()
        {
            var lang = System.Configuration.ConfigurationManager.AppSettings["LuceneDefaultCulture"];

            _serviceStoreInstance = new LuceneService(App.Config.LuceneIndexFolder, JsonMappingUtils.GetAnalyser(lang));
        }