예제 #1
0
        public virtual Filter GetFilter(XmlElement e)
        {
            string fieldName = DOMUtils.GetAttributeWithInheritance(e, "fieldName");

            string lowerTerm    = e.GetAttribute("lowerTerm");
            string upperTerm    = e.GetAttribute("upperTerm");
            bool   includeLower = DOMUtils.GetAttribute(e, "includeLower", true);
            bool   includeUpper = DOMUtils.GetAttribute(e, "includeUpper", true);

            return(TermRangeFilter.NewStringRange(fieldName, lowerTerm, upperTerm, includeLower, includeUpper));
        }
예제 #2
0
        public virtual Query GetQuery(XmlElement e)
        {
            XmlNodeList        nl          = e.GetElementsByTagName("Field");
            int                maxNumTerms = DOMUtils.GetAttribute(e, "maxNumTerms", DEFAULT_MAX_NUM_TERMS);
            FuzzyLikeThisQuery fbq         = new FuzzyLikeThisQuery(maxNumTerms, analyzer);

            fbq.IgnoreTF = DOMUtils.GetAttribute(e, "ignoreTF", DEFAULT_IGNORE_TF);

            for (int i = 0; i < nl.Count; i++)
            {
                XmlElement fieldElem     = (XmlElement)nl.Item(i);
                float      minSimilarity = DOMUtils.GetAttribute(fieldElem, "minSimilarity", DEFAULT_MIN_SIMILARITY);
                int        prefixLength  = DOMUtils.GetAttribute(fieldElem, "prefixLength", DEFAULT_PREFIX_LENGTH);
                string     fieldName     = DOMUtils.GetAttributeWithInheritance(fieldElem, "fieldName");

                string value = DOMUtils.GetText(fieldElem);
                fbq.AddTerms(value, fieldName, minSimilarity, prefixLength);
            }

            fbq.Boost = DOMUtils.GetAttribute(e, "boost", 1.0f);
            return(fbq);
        }