Error: TransportError 400, when Django-Haystack search with SQ

616 views Asked by At

Using

django-haystack==2.4.0
Elasticsearch 1.6.0

Getting TransportError 400 when:

from haystack.query import SQ

if self.cleaned_data['q']:
    term = self.cleaned_data['q']
    sqs = sqs.filter(SQ(title=term)|SQ(designation=term)|SQ(skills=term))

but below code working without any error:

if self.cleaned_data['q']:
    term = self.cleaned_data['q']
    sqs = sqs.filter(title=term)

java stack trace:

Failed to query Elasticsearch using '( OR (title:(python) OR designation:(python)))': TransportError(400, u'SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[1uj2PNSRQQWzaZRUFpuEdQ][haystack_job][0]: SearchParseException[[haystack_job][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"filtered": {"filter": {"terms": {"django_ct": ["peeldb.jobpost"]}}, "query": {"query_string": {"query": "( OR (title:(python) OR designation:(python)))", "default_operator": "OR", "default_field": "text", "auto_generate_phrase_queries": true, "analyze_wildcard": true}}}}, "from": 0, "size": 1}]]]; nested: QueryParsingException[[haystack_job] Failed to parse query [( OR (title:(python) OR designation:(python)))]]; nested: ParseException[Cannot parse \'( OR (title:(python) OR designation:(python)))\': Encountered " "OR "" at line 1, column 2.\nWas expecting one of:\n ...\n "+" ...\n "-" ...\n ...\n "(" ...\n "" ...\n ...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ...\n "" ...\n ]; nested: ParseException[Encountered " "OR "" at line 1, column 2.\nWas expecting one of:\n ...\n "+" ...\n "-" ...\n ...\n "(" ...\n "" ...\n ...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ...\n "" ...\n ]; }{[1uj2PNSRQQWzaZRUFpuEdQ][haystack_job][1]: SearchParseException[[haystack_job][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"filtered": {"filter": {"terms": {"django_ct": ["peeldb.jobpost"]}}, "query": {"query_string": {"query": "( OR (title:(python) OR designation:(python)))", "default_operator": "OR", "default_field": "text", "auto_generate_phrase_queries": true, "analyze_wildcard": true}}}}, "from": 0, "size": 1}]]]; nested: QueryParsingException[[haystack_job] Failed to parse query [( OR (title:(python) OR designation:(python)))]]; nested: ParseException[Cannot parse \'( OR (title:(python) OR designation:(python)))\': Encountered " "OR "" at line 1, column 2.\nWas expecting one of:\n ...\n "+" ...\n "-" ...\n ...\n "(" ...\n "" ...\n ...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ...\n "" ...\n ]; nested: ParseException[Encountered " "OR "" at line 1, column 2.\nWas expecting one of:\n ...\n "+" ...\n "-" ...\n ...\n "(" ...\n "" ...\n ...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ...\n "" ...\n ]; }{[1uj2PNSRQQWzaZRUFpuEdQ][haystack_job][2]: SearchParseException[[haystack_job][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"filtered": {"filter": {"terms": {"django_ct": ["peeldb.jobpost"]}}, "query": {"query_string": {"query": "( OR (title:(python) OR designation:(python)))", "default_operator": "OR", "default_field": "text", "auto_generate_phrase_queries": true, "analyze_wildcard": true}}}}, "from": 0, "size": 1}]]]; nested: QueryParsingException[[haystack_job] Failed to parse query [( OR (title:(python) OR designation:(python)))]]; nested: ParseException[Cannot parse \'( OR (title:(python) OR designation:(python)))\': Encountered " "OR "" at line 1, column 2.\nWas expecting one of:\n ...\n "+" ...\n "-" ...\n ...\n "(" ...\n "" ...\n ...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ...\n "" ...\n ]; nested: ParseException[Encountered " "OR "" at line 1, column 2.\nWas expecting one of:\n ...\n "+" ...\n "-" ...\n ...\n "(" ...\n "" ...\n ...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ...\n "" ...\n ]; }{[1uj2PNSRQQWzaZRUFpuEdQ][haystack_job][3]: SearchParseException[[haystack_job][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"filtered": {"filter": {"terms": {"django_ct": ["peeldb.jobpost"]}}, "query": {"query_string": {"query": "( OR (title:(python) OR designation:(python)))", "default_operator": "OR", "default_field": "text", "auto_generate_phrase_queries": true, "analyze_wildcard": true}}}}, "from": 0, "size": 1}]]]; nested: QueryParsingException[[haystack_job] Failed to parse query [( OR (title:(python) OR designation:(python)))]]; nested: ParseException[Cannot parse \'( OR (title:(python) OR designation:(python)))\': Encountered " "OR "" at line 1, column 2.\nWas expecting one of:\n ...\n "+" ...\n "-" ...\n ...\n "(" ...\n "" ...\n ...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ...\n "" ...\n ]; nested: ParseException[Encountered " "OR "" at line 1, column 2.\nWas expecting one of:\n ...\n "+" ...\n "-" ...\n ...\n "(" ...\n "" ...\n ...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ...\n "" ...\n ]; }{[1uj2PNSRQQWzaZRUFpuEdQ][haystack_job][4]: SearchParseException[[haystack_job][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"filtered": {"filter": {"terms": {"django_ct": ["peeldb.jobpost"]}}, "query": {"query_string": {"query": "( OR (title:(python) OR designation:(python)))", "default_operator": "OR", "default_field": "text", "auto_generate_phrase_queries": true, "analyze_wildcard": true}}}}, "from": 0, "size": 1}]]]; nested: QueryParsingException[[haystack_job] Failed to parse query [( OR (title:(python) OR designation:(python)))]]; nested: ParseException[Cannot parse \'( OR (title:(python) OR designation:(python)))\': Encountered " "OR "" at line 1, column 2.\nWas expecting one of:\n ...\n "+" ...\n "-" ...\n ...\n "(" ...\n "" ...\n ...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ...\n "" ...\n ]; nested: ParseException[Encountered " "OR "" at line 1, column 2.\nWas expecting one of:\n ...\n "+" ...\n "-" ...\n ...\n "(" ...\n "" ...\n ...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ...\n "" ...\n ]; }]') Failed to query Elasticsearch using '( OR (title:(python) OR designation:(python)))': TransportError(400, u'SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[1uj2PNSRQQWzaZRUFpuEdQ][haystack_job][0]: SearchParseException[[haystack_job][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"filtered": {"filter": {"terms": {"django_ct": ["peeldb.jobpost"]}}, "query": {"query_string": {"query": "( OR (title:(python) OR designation:(python)))", "default_operator": "OR", "default_field": "text", "auto_generate_phrase_queries": true, "analyze_wildcard": true}}}}, "from": 0}]]]; nested: QueryParsingException[[haystack_job] Failed to parse query [( OR (title:(python) OR designation:(python)))]]; nested: ParseException[Cannot parse \'( OR (title:(python) OR designation:(python)))\': Encountered " "OR "" at line 1, column 2.\nWas expecting one of:\n ...\n "+" ...\n "-" ...\n ...\n "(" ...\n "" ...\n
...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ...\n "
" ...\n ]; nested: ParseException[Encountered " "OR "" at line 1, column 2.\nWas expecting one of:\n ...\n "+" ...\n "-" ...\n
...\n "(" ...\n "" ...\n ...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ...\n "" ...\n ]; }{[1uj2PNSRQQWzaZRUFpuEdQ][haystack_job][1]: SearchParseException[[haystack_job][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"filtered": {"filter": {"terms": {"django_ct": ["peeldb.jobpost"]}}, "query": {"query_string": {"query": "( OR (title:(python) OR designation:(python)))", "default_operator": "OR", "default_field": "text", "auto_generate_phrase_queries": true, "analyze_wildcard": true}}}}, "from": 0}]]]; nested: QueryParsingException[[haystack_job] Failed to parse query [( OR (title:(python) OR designation:(python)))]]; nested: ParseException[Cannot parse \'( OR (title:(python) OR designation:(python)))\': Encountered " "OR "" at line 1, column 2.\nWas expecting one of:\n ...\n "+" ...\n "-" ...\n ...\n "(" ...\n "" ...\n
...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ...\n "
" ...\n ]; nested: ParseException[Encountered " "OR "" at line 1, column 2.\nWas expecting one of:\n ...\n "+" ...\n "-" ...\n
...\n "(" ...\n "" ...\n ...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ...\n "" ...\n ]; }{[1uj2PNSRQQWzaZRUFpuEdQ][haystack_job][2]: SearchParseException[[haystack_job][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"filtered": {"filter": {"terms": {"django_ct": ["peeldb.jobpost"]}}, "query": {"query_string": {"query": "( OR (title:(python) OR designation:(python)))", "default_operator": "OR", "default_field": "text", "auto_generate_phrase_queries": true, "analyze_wildcard": true}}}}, "from": 0}]]]; nested: QueryParsingException[[haystack_job] Failed to parse query [( OR (title:(python) OR designation:(python)))]]; nested: ParseException[Cannot parse \'( OR (title:(python) OR designation:(python)))\': Encountered " "OR "" at line 1, column 2.\nWas expecting one of:\n ...\n "+" ...\n "-" ...\n ...\n "(" ...\n "" ...\n
...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ...\n "
" ...\n ]; nested: ParseException[Encountered " "OR "" at line 1, column 2.\nWas expecting one of:\n ...\n "+" ...\n "-" ...\n
...\n "(" ...\n "" ...\n ...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ...\n "" ...\n ]; }{[1uj2PNSRQQWzaZRUFpuEdQ][haystack_job][3]: SearchParseException[[haystack_job][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"filtered": {"filter": {"terms": {"django_ct": ["peeldb.jobpost"]}}, "query": {"query_string": {"query": "( OR (title:(python) OR designation:(python)))", "default_operator": "OR", "default_field": "text", "auto_generate_phrase_queries": true, "analyze_wildcard": true}}}}, "from": 0}]]]; nested: QueryParsingException[[haystack_job] Failed to parse query [( OR (title:(python) OR designation:(python)))]]; nested: ParseException[Cannot parse \'( OR (title:(python) OR designation:(python)))\': Encountered " "OR "" at line 1, column 2.\nWas expecting one of:\n ...\n "+" ...\n "-" ...\n ...\n "(" ...\n "" ...\n
...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ...\n "
" ...\n ]; nested: ParseException[Encountered " "OR "" at line 1, column 2.\nWas expecting one of:\n ...\n "+" ...\n "-" ...\n
...\n "(" ...\n "" ...\n ...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ...\n "" ...\n ]; }{[1uj2PNSRQQWzaZRUFpuEdQ][haystack_job][4]: SearchParseException[[haystack_job][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"filtered": {"filter": {"terms": {"django_ct": ["peeldb.jobpost"]}}, "query": {"query_string": {"query": "( OR (title:(python) OR designation:(python)))", "default_operator": "OR", "default_field": "text", "auto_generate_phrase_queries": true, "analyze_wildcard": true}}}}, "from": 0}]]]; nested: QueryParsingException[[haystack_job] Failed to parse query [( OR (title:(python) OR designation:(python)))]]; nested: ParseException[Cannot parse \'( OR (title:(python) OR designation:(python)))\': Encountered " "OR "" at line 1, column 2.\nWas expecting one of:\n ...\n "+" ...\n "-" ...\n ...\n "(" ...\n "" ...\n
...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ...\n "
" ...\n ]; nested: ParseException[Encountered " "OR "" at line 1, column 2.\nWas expecting one of:\n ...\n "+" ...\n "-" ...\n
...\n "(" ...\n "" ...\n ...\n ...\n ...\n ...\n ...\n "[" ...\n "{" ...\n ...\n ...\n "" ...\n ]; }]')

0

There are 0 answers