コード例 #1
0
 public ReflectionFieldMapper(PropertyInfo propertyInfo, StoreMode store, IndexMode index, TermVectorMode termVector, TypeConverter converter, string fieldName, QueryParser.Operator defaultParserOperator, bool caseSensitive, Analyzer analyzer, float boost)
 {
     this.propertyInfo          = propertyInfo;
     this.store                 = store;
     this.index                 = index;
     this.termVector            = termVector;
     this.converter             = converter;
     this.fieldName             = fieldName;
     this.defaultParserOperator = defaultParserOperator;
     this.caseSensitive         = caseSensitive;
     this.analyzer              = analyzer;
     this.boost                 = boost;
 }
コード例 #2
0
 public ReflectionFieldMapper(PropertyInfo propertyInfo, StoreMode store, IndexMode index, TermVectorMode termVector, TypeConverter converter, string fieldName, QueryParser.Operator defaultParserOperator, bool caseSensitive, Analyzer analyzer, float boost, bool nativeSort = false)
 {
     this.propertyInfo   = propertyInfo;
     this.propertyGetter = CreatePropertyGetter(propertyInfo);
     if (propertyInfo.CanWrite)
     {
         this.propertySetter = CreatePropertySetter(propertyInfo);
     }
     this.store                 = store;
     this.index                 = index;
     this.termVector            = termVector;
     this.converter             = converter;
     this.fieldName             = fieldName;
     this.defaultParserOperator = defaultParserOperator;
     this.caseSensitive         = caseSensitive;
     this.analyzer              = analyzer;
     this.boost                 = boost;
     this.nativeSort            = nativeSort;
 }
コード例 #3
0
 /// <summary>
 /// Set the <see cref="QueryParser.DefaultOperator"/> to
 /// use <see cref="QueryParser.OR_OPERATOR"/> by default
 /// when parsing queries that contain multiple terms. This
 /// is the default behavior.
 /// </summary>
 public PropertyMap <T> ParseWithOrOperatorByDefault()
 {
     defaultParseOperator = QueryParser.Operator.OR;
     return(this);
 }
コード例 #4
0
 public static void SetDefaultOperator(this QueryParser queryParser, QueryParser.Operator value)
 {
     queryParser.DefaultOperator = value;
 }
コード例 #5
0
        /// <summary>
        /// Use a multifield query parser
        /// </summary>
        /// <param name="fields"></param>
        /// <param name="stringQuery"></param>
        /// <param name="defaultOp"></param>
        /// <returns></returns>
        public QueryBuilder MatchParsedInput(IEnumerable <string> fields, string stringQuery, QueryParser.Operator defaultOp = null)
        {
            if (string.IsNullOrWhiteSpace(stringQuery))
            {
                return(this);
            }

            var parser = new MultiFieldQueryParser(Version, fields.ToArray(), _analyzer);

            if (defaultOp != null)
            {
                parser.SetDefaultOperator(defaultOp);
            }

            Query query;

            try
            {
                query = parser.Parse(stringQuery);
            }
            catch (ParseException)
            {
                query = parser.Parse(QueryParser.Escape(stringQuery.ToLower()));
            }

            return(query != null?AddSubQuery(query) : this);
        }
コード例 #6
0
 private ReflectionFieldMapper <ReflectionFieldMapperTests> CreateMapper(string propertyName, TypeConverter converter = null, Analyzer analyzer = null, QueryParser.Operator defaultParseOperaor = QueryParser.Operator.OR, bool caseSensitive = false)
 {
     return(new ReflectionFieldMapper <ReflectionFieldMapperTests>(
                typeof(ReflectionFieldMapperTests).GetProperty(propertyName),
                StoreMode.Yes,
                IndexMode.Analyzed, TermVectorMode.No, converter, propertyName, defaultParseOperaor, caseSensitive, analyzer ?? new KeywordAnalyzer(), 1f));
 }