Search code examples
djangoelasticsearchfull-text-searchdjango-haystack

Unable to search '#' in elasticsearch


This query -

curl -XGET http://localhost:9200/haystack/modelresult/_search?q=post_text:#test

fails to execute with an error

SearchPhaseExecutionException[Failed to execute phase

with status 400


Solution

  • Try this:

    curl -XPOST "http://localhost:9200/haystack/modelresult/_search" -d'
    {
        "query": {
            "match": {
               "post_text": "#test"
            }
        }
    }'
    

    or this:

    curl -XPOST "http://localhost:9200/haystack/modelresult/_search" -d'
    {
        "query": {
            "term": {
               "post_text": "#test"
            }
        }
    }'