0

Hello All i am having a problem that when i was using query_string with mappings given below everything was working fine i am just using default analyzers with no filters.

mappings : {
    places_area1: {
      properties:{
        area1         : {"type" : "string", "index": "analyzed"},
        city         : {"type" : "string", "index": "analyzed"}
        },
      }
    }
  }
}

but now when i am trying to use query_string with this mapping it is not working can someone please tell me what am i doing wrong, i guess its because of whitespace tokenizer but why.

"settings": {
    "index": {
      "analysis": {
        "analyzer": {
          "synonym_wildcard": {
            "tokenizer": "whitespace",
            "filter": ["filter_wildcard"]
          },
          "synonym_term": {
            "tokenizer": "keyword",
            "filter": ["filter_term"]
          },
          "simple_wildcard": {
            "tokenizer": "whitespace"
          }
        },
        "filter": {
          "filter_term": {
            "tokenizer": "keyword", // here you have to write this only for tokenizer keyword but not for whitespace
            "type": "synonym",
            "synonyms_path": "synonyms.txt",
          },
          "filter_wildcard": {
            "type": "synonym",
            "synonyms_path": "synonyms.txt",
          }
        }
      }
    }
  },
  mappings : {
    places_area1: {
      properties:{
        area1         : {"type" : "string", "index": "analyzed", "analyzer": "simple_wildcard"},
        city         : {"type" : "string", "fields": {
          "raw": {
            "type": "string",
            "analyzer": "synonym_term"
          },
          "raw_wildcard": {
            "type": "string",
            "analyzer": "synonym_wildcard"
          }
        } },
      }
    }
  }
}
5
  • what word or string you are trying to match with query_string? Commented Nov 20, 2015 at 19:55
  • i am trying to search starting with Ban so query is Ban* Commented Nov 20, 2015 at 20:01
  • hey chintan can i add you on facebook ?? Commented Nov 20, 2015 at 20:02
  • what document your query should match? Commented Nov 20, 2015 at 20:17
  • dont focus on document its already there because when i am using wildcard search query it is returning Bangalore. So i guess problem is somewhere else ?? Commented Nov 20, 2015 at 20:26

1 Answer 1

1

I think the problem could be your query is lowercased because by default "lowercase_expanded_terms" is true

 {
      "query": {
        "query_string": {
          "default_field": "state",
          "query": "Ban*",
          "lowercase_expanded_terms": false
        }
      }
    }

Now this should match Bangalore

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.