Skip to content

Query vs JObject Search strategy problem #11

@paratoner

Description

@paratoner

Hi again,
When i use
ISearchResult Search(JObject query, string contentType = "")
method index configuration Field Strategy is :
DotJEM.Json.Index.Configuration.FieldStrategies.FieldStrategy
but when i use
ISearchResult Search(Query query) method
the Field Strategy is :

DotJEM.Json.Index.Configuration.FieldStrategies.TermFieldStrategy

can you explain why this reason?
Because it occur problem for me.
For example :

var query = JObject.Parse("{\"Name\":\"Lill\"}");
 List <dynamic> result = index.Searcher.Search(query).Select(hit => hit.Json).ToList();

it returns result. but i have not a person that named "Lill". it is name is Lilly. this method adds wildcardquery due to the FieldStrategy

  public virtual Query BuildQuery(string field, string value)
        {
            value = value.ToLowerInvariant();
            string[] words = value.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
            if (!words.Any())
                return null;

            BooleanQuery query = new BooleanQuery();
            foreach (string word in words)
            {
                //Note: As for the WildcardQuery, we only add the wildcard to the end for performance reasons.
                query.Add(new FuzzyQuery(new Term(field, word)), Occur.SHOULD);
                query.Add(new WildcardQuery(new Term(field, word + "*")), Occur.SHOULD);
            }
            return query;
        }

but when i use

Query query = new TermQuery(new Term("Name", @"Lill"));
List <dynamic> result = index.Searcher.Search(query).Select(hit => hit.Json).ToList();

it returns 0 result and it is correct.

i dont want to change your source code . So can you give me a trick for this problem?
sorry about my english.
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions