Inheritance: SearchComponentBase
示例#1
0
        public static List<Facet> GetAllCategoriesByNodeDistinct(Facet facet, List<Metadata> metadataList)
        {
            List<Facet> l = new List<Facet>();

            foreach (Metadata m in metadataList)
            {
                foreach (XmlNode x in m.GetValueFromNode(facet.Name))
                {
                    bool isIn = false;
                    foreach (Facet s in l)
                    {
                        if (x.InnerText == s.Name)
                        {
                            s.Count++;
                            s.Text = s.Name;
                            isIn = true;
                        }
                    }

                    if (isIn == false)
                    {
                        Facet c = new Facet();
                        c.Parent = facet;
                        c.Name = x.InnerText;
                        c.Count = 1;
                        c.Text = c.Name;
                        l.Add(c);
                    }
                }
            }

            return l;
        }
示例#2
0
        /// <summary>
        /// Check if facet in SerachCriteriaList
        /// This function is used to check whether an facet is present in the list.
        /// </summary>
        /// <remarks></remarks>
        /// <seealso cref=""/>
        /// <param name="facet"></param>
        /// <returns></returns>
        public bool ContainsFacet(Facet facet)
        {
            var isIn = (from sco in SearchCriteriaList
                        from v in sco.Values
                        where (sco.SearchComponent.Name.Equals(facet.Parent.Name) && v.Equals(facet.Name, StringComparison.InvariantCulture)) ||
                        sco.SearchComponent.Name.Equals(facet.Name, StringComparison.InvariantCulture)
                        select sco).Count() > 0;

            return isIn;
        }
示例#3
0
        /// <summary>
        /// <para>Get all node from type and there childrens from the metadata list.</para>
        /// <para>The static type define the possible types:</para>
        /// <list type="bullet">
        /// <listheader>
        /// <term>types</term>
        /// <description>description</description>
        /// </listheader>
        /// <item>
        /// <term>CATEGORY_TYPE</term>
        /// <description>description</description>
        ///</item>
        ///<item>
        /// <term>DROPDOWN_TYPE</term>
        /// <description>description</description>
        ///</item>
        ///</list>
        /// </summary>
        /// <param name="type">criteria/dropbox</param>
        /// <param name="metadataList">list of metadata objects</param>
        /// <returns> retrun all nodes as IEnumerable from a Metadata List </returns>
        public static IEnumerable<Facet> GetAllNodesAsListFromData(string type, List<Metadata> metadataList)
        {
            LoadXml();
            List<Facet> l = new List<Facet>();

            XmlNodeList typeList = _source.GetElementsByTagName(type);
            XmlNode root = typeList.Item(0);

            foreach (XmlNode x in root.ChildNodes)
            {
                Facet c = new Facet();
                c.Name = x.LocalName;
                c.Text = x.LocalName;
                c.Value = x.LocalName;
                c.Childrens = new List<Facet>();

                List<Facet> lc = MetadataReader.GetAllCategoriesByNodeDistinct(c, metadataList);

                if (lc.Count()>0)
                {
                    int childCount = 0;
                    foreach (Facet c_child in lc)
                    {
                        childCount += c_child.Count;
                        c.Childrens.Add(c_child);

                    }

                    c.Text = c.Name;
                    c.Count += childCount;
                }
                else c.Count = 0;
                l.Add(c);
            }
            return l;
        }
示例#4
0
 /// <summary>
 /// 
 /// </summary>
 /// <remarks></remarks>
 /// <seealso cref=""/>
 /// <param name="query"></param>
 /// <param name="facets"></param>
 /// <returns></returns>
 public static IEnumerable<Facet> facetSearch(Query query, IEnumerable<Facet> facets)
 {
     List<Facet> l = new List<Facet>();
     foreach (Facet f in facets)
     {
         Facet c = new Facet();
         c.Name = f.Name;
         c.Text = f.Text;
         c.Value = f.Value;
         c.DisplayName = f.DisplayName;
         c.Childrens = new List<Facet>();
         SimpleFacetedSearch sfs = new SimpleFacetedSearch(_Reader, new string[] { "facet_" + f.Name });
         SimpleFacetedSearch.Hits hits = sfs.Search(query);
         int cCount = 0;
         foreach (SimpleFacetedSearch.HitsPerFacet hpg in hits.HitsPerFacet)
         {
             if (!hpg.Name.ToString().Equals(""))
             {
                 Facet cc = new Facet();
                 cc.Name = hpg.Name.ToString();
                 cc.Text = hpg.Name.ToString();
                 cc.Value = hpg.Name.ToString();
                 cc.Count = (int)hpg.HitCount;
                 if (cc.Count > 0) cCount++;
                 c.Childrens.Add(cc);
             }
         }
         c.Count = cCount;
         l.Add(c);
     }
     return l;
 }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        /// <remarks></remarks>
        /// <seealso cref=""/>        
        private void LoadBeforeIndexing()
        {
            XmlNodeList fieldProperties = configXML.GetElementsByTagName("field");
            Category category = new Category();
            category.Name = "All";
            category.Value = "All";
            category.DefaultValue = "nothing";
            AllCategories.Add(category);
            foreach (XmlNode fieldProperty in fieldProperties)
            {
                String fieldType = fieldProperty.Attributes.GetNamedItem("type").Value;
                String fieldName = fieldProperty.Attributes.GetNamedItem("lucene_name").Value;

                if (fieldType.ToLower().Equals("facet_field"))
                {
                    facetXmlNodeList.Add(fieldProperty);
                    Facet c = new Facet();
                    c.Name = fieldName;
                    c.Text = fieldName;
                    c.Value = fieldName;
                    //c.Expanded = true;
                    //c.Enabled = true;
                    c.Childrens = new List<Facet>();
                    AllFacets.Add(c);
                }

                else if (fieldType.ToLower().Equals("property_field"))
                {
                    propertyXmlNodeList.Add(fieldProperty);
                    Property c = new Property();
                    c.Name = fieldProperty.Attributes.GetNamedItem("lucene_name").Value;
                    c.DisplayName = fieldProperty.Attributes.GetNamedItem("display_name").Value; ;

                    c.DataSourceKey = fieldProperty.Attributes.GetNamedItem("metadata_name").Value;

                    c.UIComponent = fieldProperty.Attributes.GetNamedItem("uiComponent").Value; ;
                    c.AggregationType = "distinct";
                    c.DefaultValue = "All";
                    c.DataType = fieldProperty.Attributes.GetNamedItem("primitive_type").Value;
                    AllProperties.Add(c);
                }
                else if (fieldType.ToLower().Equals("category_field") || fieldType.ToLower().Equals("primary_data_field"))
                {
                    categoryXmlNodeList.Add(fieldProperty);
                    Category c = new Category();
                    c.Name = fieldProperty.Attributes.GetNamedItem("lucene_name").Value;
                    c.Value = fieldProperty.Attributes.GetNamedItem("lucene_name").Value; ;
                    c.DefaultValue = "nothing";
                    AllCategories.Add(c);
                }
                else if (fieldType.ToLower().Equals("general_field"))
                {
                    generalXmlNodeList.Add(fieldProperty);
                }
            }
        }