Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <remarks></remarks>
        /// <seealso cref=""/>
        /// <param name="searchCriteria"></param>
        /// <param name="pageSize"></param>
        /// <param name="currentPage"></param>
        /// <returns></returns>
        public SearchModel Get(SearchCriteria searchCriteria, int pageSize = 10, int currentPage = 1)
        {
            getQueryFromCriteria(searchCriteria);
            this.WorkingSearchModel.ResultComponent = BexisIndexSearcher.search(bexisSearching, SearchConfig.headerItemXmlNodeList);

            return(this.WorkingSearchModel);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <remarks></remarks>
        /// <seealso cref=""/>
        /// <param name="searchCriteria"></param>
        /// <param name="pageSize"></param>
        /// <param name="currentPage"></param>
        /// <returns></returns>
        public SearchModel SearchAndUpdate(SearchCriteria searchCriteria, int pageSize = 10, int currentPage = 1)
        {
            this.WorkingSearchModel = Get(searchCriteria, pageSize, currentPage);
            this.WorkingSearchModel = UpdateFacets(searchCriteria);

            return(this.WorkingSearchModel);
        }
Ejemplo n.º 3
0
        public SearchModel UpdateProperties(SearchCriteria searchCriteria = null)
        {
            if (searchCriteria == null)
            {
                searchCriteria = new SearchCriteria();
            }
            getQueryFromCriteria(searchCriteria);

            this.WorkingSearchModel.SearchComponent.Properties = BexisIndexSearcher.propertySearch(this.bexisSearching, this.WorkingSearchModel.SearchComponent.Properties);

            return(this.WorkingSearchModel);
        }
Ejemplo n.º 4
0
        public SearchModel UpdateFacets(SearchCriteria searchCriteria = null)
        {
            if (searchCriteria == null)
            {
                searchCriteria = new SearchCriteria();
            }
            getQueryFromCriteria(searchCriteria);

            this.WorkingSearchModel.SearchComponent.Facets = BexisIndexSearcher.facetSearch(this.bexisSearching, this.WorkingSearchModel.SearchComponent.Facets);

            return(this.WorkingSearchModel);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Remove a property from the Dictionary
        /// </summary>
        /// <example>
        /// grassland: all | yes | no
        /// grassland is name
        /// value is (all | yes | no)
        /// </example>
        /// <param name="name">Name of the property</param>
        /// <param name="value">Value of the property</param>
        public void RemoveFromPropertiesDic(string name, string value, SearchCriteria sc)
        {
            if (name != null)
            {
                if (sc.GetProperty(name) != null)
                {
                    string datasourceKey = sc.GetProperty(name).DataSourceKey;

                    if (PropertiesDic.ContainsKey(datasourceKey))
                    {
                        foreach (KeyValuePair <string, string> kvp in PropertiesDic)
                        {
                            if (kvp.Value == value && kvp.Key == datasourceKey)
                            {
                                PropertiesDic.Remove(datasourceKey);
                                break;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 ///
 /// </summary>
 /// <remarks></remarks>
 /// <seealso cref=""/>
 /// <param name="searchCriteria"></param>
 /// <return></return>
 private void getQueryFromCriteria(SearchCriteria searchCriteria)
 {
     if (searchCriteria.SearchCriteriaList.Count() > 0)
     {
         bexisSearching = new BooleanQuery();
         foreach (SearchCriterion sco in searchCriteria.SearchCriteriaList)
         {
             if (sco.Values.Count > 0)
             {
                 if (sco.SearchComponent.Type.Equals(SearchComponentBaseType.General))
                 {
                     String       fieldName             = sco.SearchComponent.Name;
                     BooleanQuery bexisSearchingGeneral = new BooleanQuery();
                     foreach (String value in sco.Values)
                     {
                         String encodedValue = value;
                         Query  query        = new TermQuery(new Term(fieldName, encodedValue));
                         bexisSearchingGeneral.Add(query, Occur.SHOULD);
                     }
                     ((BooleanQuery)bexisSearching).Add(bexisSearchingGeneral, Occur.MUST);
                 }
                 else if (sco.SearchComponent.Type.Equals(SearchComponentBaseType.Category))
                 {
                     BooleanQuery bexisSearchingCategory = new BooleanQuery();
                     String       fieldName = "category_" + sco.SearchComponent.Name;
                     QueryParser  parser;
                     if (fieldName.ToLower().Equals("category_all"))
                     {
                         List <string> temp2 = BexisIndexSearcher.getCategoryFields().ToList();
                         temp2.AddRange(BexisIndexSearcher.getStoredFields().ToList());
                         temp2.Add("ng_all");
                         parser = new MultiFieldQueryParser(Lucene.Net.Util.Version.LUCENE_30, temp2.ToArray(), new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30));
                     }
                     else
                     {
                         parser = new QueryParser(Lucene.Net.Util.Version.LUCENE_30, fieldName, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30));
                     }
                     foreach (String value in sco.Values)
                     {
                         String encodedValue = EncoderHelper.Encode(value);
                         String newString    = null;
                         //string value = val.Replace(")", "").Replace("(", "");
                         char[]   delimiter = new char[] { ';', ' ', ',', '!', '.' };
                         string[] parts     = encodedValue.ToLower().Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
                         for (int i = 0; i < parts.Length; i++)
                         {
                             newString = newString + " " + parts[i] + "~0.6";
                         }
                         parser.PhraseSlop      = 5;
                         parser.DefaultOperator = QueryParser.AND_OPERATOR;
                         string query_value = encodedValue;
                         if (encodedValue.Equals(""))
                         {
                             query_value = "*:*";
                         }
                         Query query = parser.Parse(query_value);
                         bexisSearchingCategory.Add(query, Occur.SHOULD);
                     }
                     ((BooleanQuery)bexisSearching).Add(bexisSearchingCategory, Occur.MUST);
                 }
                 else if (sco.SearchComponent.Type.Equals(SearchComponentBaseType.Facet))
                 {
                     String       fieldName           = "facet_" + sco.SearchComponent.Name;
                     BooleanQuery bexisSearchingFacet = new BooleanQuery();
                     foreach (String value in sco.Values)
                     {
                         String encodedValue = value;
                         Query  query        = new TermQuery(new Term(fieldName, encodedValue));
                         bexisSearchingFacet.Add(query, Occur.SHOULD);
                     }
                     ((BooleanQuery)bexisSearching).Add(bexisSearchingFacet, Occur.MUST);
                 }
                 else if (sco.SearchComponent.Type.Equals(SearchComponentBaseType.Property))
                 {
                     String   fieldName = "property_" + sco.SearchComponent.Name;
                     Property pp        = (Property)sco.SearchComponent;
                     if (pp.UIComponent.ToLower().Equals("range"))
                     {
                         fieldName = "property_numeric_" + sco.SearchComponent.Name;
                         DateTime dd = new DateTime(Int32.Parse(sco.Values[0]), 1, 1, 1, 1, 1);
                         if (pp.Direction == Direction.increase)
                         {
                             NumericRangeQuery <long> dateRangeQuery = NumericRangeQuery.NewLongRange(fieldName, dd.Ticks, long.MaxValue, true, true);
                             ((BooleanQuery)bexisSearching).Add(dateRangeQuery, Occur.MUST);
                         }
                         else
                         {
                             NumericRangeQuery <long> dateRangeQuery = NumericRangeQuery.NewLongRange(fieldName, long.MinValue, dd.Ticks, true, true);
                             ((BooleanQuery)bexisSearching).Add(dateRangeQuery, Occur.MUST);
                         }
                     }
                     else
                     {
                         BooleanQuery bexisSearchingProperty = new BooleanQuery();
                         foreach (String value in sco.Values)
                         {
                             if (value.ToLower().Equals("all"))
                             {
                                 Query query = new MatchAllDocsQuery();
                                 bexisSearchingProperty.Add(query, Occur.SHOULD);
                             }
                             else
                             {
                                 String encodedValue = value;
                                 if (SearchConfig.getNumericProperties().Contains(sco.SearchComponent.Name.ToLower()))
                                 {
                                 }
                                 else
                                 {
                                     Query query = new TermQuery(new Term(fieldName, encodedValue));
                                     bexisSearchingProperty.Add(query, Occur.SHOULD);
                                 }
                             }
                         }
                         ((BooleanQuery)bexisSearching).Add(bexisSearchingProperty, Occur.MUST);
                     }
                 }
             }
             else
             {
                 //do nothing yet
             }
         }
     }
     else
     {
         using (var sa = new SimpleAnalyzer())
         {
             QueryParser parser = new QueryParser(Lucene.Net.Util.Version.LUCENE_30, "id", sa);
             bexisSearching = parser.Parse("*:*");
         }
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 ///
 /// </summary>
 /// <remarks></remarks>
 /// <seealso cref=""/>
 /// <param name="searchCriteria"></param>
 /// <return></return>
 public void SearchAndUpdate(SearchCriteria searchCriteria)
 {
     this.WorkingSearchModel = Get(searchCriteria);
     this.WorkingSearchModel = UpdateFacets(searchCriteria);
     this.WorkingSearchModel = UpdateProperties(searchCriteria);
 }
Ejemplo n.º 8
0
 /// <summary>
 ///
 /// </summary>
 /// <remarks></remarks>
 /// <seealso cref=""/>
 /// <param name="value"></param>
 /// <param name="filter"></param>
 /// <param name="searchType"></param>
 /// <param name="numberOfResults"></param>
 /// <param name="searchCriteria"></param>
 /// <returns></returns>
 public SearchModel GetTextBoxSearchValues(string value, string filter, string searchType, int numberOfResults, SearchCriteria searchCriteria)
 {
     throw new NotImplementedException();
 }