Пример #1
0
        private AnalyzeResponse _Analyze(AnalyzeParams analyzeParams, string text)
        {
            var path = this.PathResolver.CreateIndexPath(analyzeParams.Index, "_analyze") + "?text=";

            path += Uri.EscapeDataString(text);

            if (!analyzeParams.Field.IsNullOrEmpty())
            {
                path += "&field=" + analyzeParams.Field;
            }
            else if (!analyzeParams.Analyzer.IsNullOrEmpty())
            {
                path += "&analyzer=" + analyzeParams.Analyzer;
            }
            else
            {
                //Build custom analyzer out of tokenizers and filters
                if (!analyzeParams.Filters.IsNullOrEmpty())
                {
                    path += "&filters=" + analyzeParams.Filters;
                }
                if (!analyzeParams.Tokenizer.IsNullOrEmpty())
                {
                    path += "&tokenizer=" + analyzeParams.Tokenizer;
                }
            }

            var status = this.Connection.GetSync(path);
            var r      = this.ToParsedResponse <AnalyzeResponse>(status);

            return(r);
        }
Пример #2
0
 public void SimplAnalyzeDifferentIndexAndField()
 {
     //analyze text using a different index and custom analyzer
     var text = "this is a string with some spaces and stuff";
     var analyzer = new AnalyzeParams { Field = "content", Index = Test.Default.DefaultIndex + "_clone" };
     var r = this.ConnectedClient.Analyze(analyzer, text);
     this._defaultAnalyzeAssertations(r);
     Assert.False(r.Tokens.Count() == text.Split(new[] { ' ' }).Count());
 }
Пример #3
0
        /// <summary>
        ///  Analyzes text according to the current analyzer of the field in the passed index.
        /// </summary>
        public IAnalyzeResponse Analyze <T>(Expression <Func <T, object> > selector, string index, string text) where T : class
        {
            selector.ThrowIfNull("selector");
            var fieldName     = this.PropertyNameResolver.Resolve(selector);
            var analyzeParams = new AnalyzeParams()
            {
                Index = index, Field = fieldName
            };

            return(this._Analyze(analyzeParams, text));
        }
Пример #4
0
        private AnalyzeResponse _Analyze(AnalyzeParams analyzeParams, string text)
        {
            var path = this.CreatePath(analyzeParams.Index) + "_analyze?text=";

            path += Uri.EscapeDataString(text);

            if (!analyzeParams.Field.IsNullOrEmpty())
            {
                path += "&field=" + analyzeParams.Field;
            }
            else if (!analyzeParams.Analyzer.IsNullOrEmpty())
            {
                path += "&analyzer=" + analyzeParams.Analyzer;
            }

            var status = this.Connection.GetSync(path);
            var r      = this.ToParsedResponse <AnalyzeResponse>(status);

            return(r);
        }
Пример #5
0
 /// <summary>
 /// Analyzes specified text according to the analyzeparams passed.
 /// </summary>
 /// <returns>AnalyzeResponse contains a breakdown of the token under .Tokens</returns>
 public IAnalyzeResponse Analyze(AnalyzeParams analyzeParams, string text)
 {
     analyzeParams.ThrowIfNull("analyzeParams");
     analyzeParams.Index.ThrowIfNull("analyzeParams.Index");
     return(this._Analyze(analyzeParams, text));
 }