Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-46704

QueryError at /api/search/

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Low
    • None
    • No-Version

    Description

      NOTE: This bug report is for Confluence Server. Using Confluence Cloud? See the corresponding bug report.

      QueryError at /api/search/

      Phrase search: u'tags' field has no positions
      Request Method: POST
      Request URL: http://answers.atlassian.com/api/search/
      Django Version: 1.2.5
      Exception Type: QueryError
      Exception Value:
      Phrase search: u'tags' field has no positions
      Exception Location: /opt/python/domains/atlassian.com/answers/lib/python2.6/site-packages/whoosh/query.py in matcher, line 1767
      Python Executable: /opt/python/domains/atlassian.com/answers/bin/python2.6
      Python Version: 2.6.5
      Python Path: ['/opt/python/domains/atlassian.com/answers/ADM-22880', '/opt/python/domains/atlassian.com/answers', '/opt/python/domains/atlassian.com/answers/bin', '/opt/python/domains/atlassian.com/answers/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg', '/opt/python/domains/atlassian.com/answers/lib/python2.6/site-packages/pip-0.8.3-py2.6.egg', '/opt/python/domains/atlassian.com/answers/lib64/python26.zip', '/opt/python/domains/atlassian.com/answers/lib64/python2.6', '/opt/python/domains/atlassian.com/answers/lib64/python2.6/plat-linux2', '/opt/python/domains/atlassian.com/answers/lib64/python2.6/lib-tk', '/opt/python/domains/atlassian.com/answers/lib64/python2.6/lib-old', '/opt/python/domains/atlassian.com/answers/lib64/python2.6/lib-dynload', '/usr/lib/python2.6', '/usr/lib64/python2.6', '/opt/python/domains/atlassian.com/answers/lib/python2.6/site-packages', '/opt/python/domains/atlassian.com/answers/lib/python2.6/site-packages/PIL', '/usr/lib/python2.6/site-packages/pip-0.8.3-py2.6.egg', '/usr/lib/python2.6/site-packages', '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info', '/usr/lib64/python2.6/site-packages', '/opt/python/domains/atlassian.com/answers/ADM-22880/forum/markdownext']
      Server time: Fri, 27 Apr 2012 16:58:30 -0400
      Traceback Switch to copy-and-paste view

      /opt/python/domains/atlassian.com/answers/ADM-22880/forum_modules/atlassian/api/handlers.py in create
      return self.linksDoc(request)
      def create(self, request):
      data = QueryDict(request.GET.urlencode(), True)
      if request.data:
      data.update(request.data)
      if 'query' in data or 'tags' in data or 'tag' in data:
      return self.do_search(data) ...
      else:
      res = rc.BAD_REQUEST
      res.write('\nQuery must contain one or more "query" or "tag" params.\nPOST with application/json or use GET')
      return res
      def do_search(self, data):
      ▶ Local vars
      Variable Value
      data
      <QueryDict:

      {u'query': [u'Confluence Developer Documentation'], u'tag': [[u'confluence-plugins', u'confluence-development']]}

      >
      request
      <WSGIRequest GET:<QueryDict: {}>, POST:{}, COOKIES:{}, META:

      {'CONTENT_LENGTH': '114', 'CONTENT_TYPE': 'application/json; charset=utf-8', 'CSRF_COOKIE': '08a435fc631bcb05ff3b5253272e610f', 'HTTP_CONNECTION': 'close', 'HTTP_HOST': 'answers.atlassian.com', 'HTTP_USER_AGENT': 'Jakarta Commons-HttpClient/3.1', 'HTTP_X_FORWARDED_FOR': '63.246.22.222, 172.16.3.45', 'HTTP_X_REAL_IP': '63.246.22.222', 'PATH_INFO': u'/api/search/', 'QUERY_STRING': '', 'RAW_URI': '/api/search/', 'REMOTE_ADDR': '172.16.3.45', 'REMOTE_PORT': '80', 'REQUEST_METHOD': 'POST', 'SCRIPT_NAME': u'', 'SERVER_NAME': 'answers.atlassian.com', 'SERVER_PORT': '80', 'SERVER_PROTOCOL': 'HTTP/1.0', 'SERVER_SOFTWARE': 'gunicorn/0.14.1', 'gunicorn.socket': <socket._socketobject object at 0x22672910>, 'wsgi.errors': <open file '<stderr>', mode 'w' at 0x2b3e72f401e0>, 'wsgi.file_wrapper': <class gunicorn.http.wsgi.FileWrapper at 0x1feeaf50>, 'wsgi.input': <gunicorn.http.body.Body object at 0x223c6390>, 'wsgi.multiprocess': True, 'wsgi.multithread': False, 'wsgi.run_once': False, 'wsgi.url_scheme': 'http', 'wsgi.version': (1, 0)}

      >
      self
      <forum_modules.atlassian.api.handlers.SearchHandler object at 0x215fe350>
      /opt/python/domains/atlassian.com/answers/ADM-22880/forum_modules/atlassian/api/handlers.py in do_search
      }.get(sort, sort)
      search_results = SearchQuerySet()
      if 'query' in data:
      search_results = search_results.filter(content=data['query'])
      if 'tag' in data:
      search_results = search_results.filter(tags__in=data.getlist('tag'))
      length = search_results.count() ...
      if sort:
      search_results = search_results.order_by(sort)
      while offset < 0:
      offset += length
      end = offset+limit

      1. Seems Haystack 1.2.6's slice is somewhat broken – sqs[start:end]
        ▶ Local vars
        Variable Value
        _sort
        None
        bad_request
        <function bad_request at 0x2aaaba4569b0>
        data
        <QueryDict: {u'query': [u'Confluence Developer Documentation'], u'tag': [[u'confluence-plugins', u'confluence-development']]}

        >
        limit
        5
        offset
        0
        reversed
        False
        search_results
        Error in formatting: Phrase search: u'tags' field has no positions
        self
        <forum_modules.atlassian.api.handlers.SearchHandler object at 0x215fe350>
        sort
        None
        tag
        [[u'confluence-plugins', u'confluence-development']]
        Variable Value
        self
        <haystack.backends.whoosh_backend.SearchQuery object at 0x223c61d0>
        /opt/python/domains/atlassian.com/answers/lib/python2.6/site-packages/haystack/backends/_init_.py in run
        return kwargs
        def run(self, spelling_query=None):
        """Builds and executes the query. Returns a list of search results."""
        final_query = self.build_query()
        kwargs = self.build_params(spelling_query=spelling_query)
        results = self.backend.search(final_query, **kwargs) ...
        self._results = results.get('results', [])
        self._hit_count = results.get('hits', 0)
        self._facet_counts = self.post_process_facets(results)
        self._spelling_suggestion = results.get('spelling_suggestion', None)
        def run_mlt(self):
        ▶ Local vars
        Variable Value
        final_query
        u'("Confluence Developer Documentation" AND (tags:"confluence-plugins,confluence-development"))'
        kwargs

        {'end_offset': 10, 'result_class': <class 'haystack.models.SearchResult'>, 'start_offset': 0}

        self
        <haystack.backends.whoosh_backend.SearchQuery object at 0x223c61d0>
        spelling_query
        None
        /opt/python/domains/atlassian.com/answers/lib/python2.6/site-packages/haystack/backends/_init_.py in wrapper
        A decorator for pseudo-logging search queries. Used in the ``SearchBackend``
        to wrap the ``search`` method.
        """
        def wrapper(obj, query_string, *args, **kwargs):
        start = time()
        try:
        return func(obj, query_string, *args, **kwargs) ...
        finally:
        stop = time()
        if settings.DEBUG:
        global queries
        queries.append(

        Unknown macro: {▶ Local varsVariable Valueargs ()func <function search at 0x20cdf230>kwargs {'end_offset': 10, 'result_class': <class 'haystack.models.SearchResult'>, 'start_offset': 0}obj <haystack.backends.whoosh_backend.SearchBackend object at 0x223c6810>query_string u'("Confluence Developer Documentation" AND (tags}

        limit_to_registered_models
        True
        narrow_queries
        set([u'django_ct:forum.question'])
        narrow_searcher
        <whoosh.searching.Searcher object at 0x2214f550>
        narrowed_results
        <Top 10 Results for Term(u'django_ct', u'forum.question') runtime=0.103665828705>
        nq
        u'django_ct:forum.question'
        parsed_query
        And([Phrase('text', [u'confluenc', u'develop', u'document'], slop=1, boost=1.000000), Phrase(u'tags', [u'confluence-plugins', u'confluence-development'], slop=1, boost=1.000000)])
        query_facets
        None
        query_string
        u'("Confluence Developer Documentation" AND (tags:"confluence-plugins,confluence-development"))'
        recent_narrowed_results
        <Top 10 Results for Term(u'django_ct', u'forum.question') runtime=0.103665828705>
        registered_models
        [u'forum.question']
        result_class
        <class 'haystack.models.SearchResult'>
        reverse
        False
        rm
        u'forum.question'
        searcher
        <whoosh.searching.Searcher object at 0x2289f450>
        self
        <haystack.backends.whoosh_backend.SearchBackend object at 0x223c6810>
        sort_by
        None
        spelling_query
        None
        start_offset
        0
        /opt/python/domains/atlassian.com/answers/lib/python2.6/site-packages/whoosh/searching.py in search
        groupedby=groupedby, terms=terms,
        maptype=maptype)
        if sortedby:
        return collector.sort(self, q, sortedby, reverse=reverse,
        allow=filter, restrict=mask)
        else:
        return collector.search(self, q, allow=filter, restrict=mask) ...
        def correct_query(self, q, qstring, correctors=None, allfields=False,
        terms=None, prefix=0, maxdist=2):
        """Returns a corrected version of the given user query using a default
        :class:`whoosh.spelling.ReaderCorrector`.
        ▶ Local vars
        Variable Value
        collector
        <whoosh.searching.Collector object at 0x220e1ad0>
        filter
        None
        groupedby
        None
        limit
        10
        maptype
        None
        mask
        None
        optimize
        True
        q
        And([Phrase('text', [u'confluenc', u'develop', u'document'], slop=1, boost=1.000000), Phrase(u'tags', [u'confluence-plugins', u'confluence-development'], slop=1, boost=1.000000)])
        reverse
        False
        self
        <whoosh.searching.Searcher object at 0x2289f450>
        sortedby
        None
        terms
        False
        /opt/python/domains/atlassian.com/answers/lib/python2.6/site-packages/whoosh/searching.py in search
        else:
        searchers = searcher.subsearchers
        for s, offset in searchers:
        scorefn = self._score_fn(s)
        self.subsearcher = s
        self._set_categorizers(s, offset)
        self.add_matches(q, offset, scorefn) ...

      2. If we started a time limit timer thread, cancel it
        if self.timelimit and self.timer:
        self.timer.cancel()
        self.runtime = now() - t
        ▶ Local vars
        Variable Value
        allow
        None
        offset
        24
        q
        And([Phrase('text', [u'confluenc', u'develop', u'document'], slop=1, boost=1.000000), Phrase(u'tags', [u'confluence-plugins', u'confluence-development'], slop=1, boost=1.000000)])
        restrict
        None
        s
        <whoosh.searching.Searcher object at 0x2aaab7b5f210>
        scorefn
        None
        searcher
        <whoosh.searching.Searcher object at 0x2289f450>
        searchers
        [(<whoosh.searching.Searcher object at 0x2aaab7b5f290>, 0), (<whoosh.searching.Searcher object at 0x2aaab7b5f550>, 11), (<whoosh.searching.Searcher object at 0x2aaab7b5f210>, 24), (<whoosh.searching.Searcher object at 0x2aaab7b5f810>, 295), (<whoosh.searching.Searcher object at 0x2aaab7b5ff50>, 1295), (<whoosh.searching.Searcher object at 0x2aaab7b5f850>, 2295), (<whoosh.searching.Searcher object at 0x2aaab7b5fa10>, 3295), (<whoosh.searching.Searcher object at 0x2aaab7b5f6d0>, 4295), (<whoosh.searching.Searcher object at 0x2aaab7b5fcd0>, 5295), (<whoosh.searching.Searcher object at 0x220e14d0>, 6295), (<whoosh.searching.Searcher object at 0x220e1c10>, 7295), (<whoosh.searching.Searcher object at 0x220e1ed0>, 8295), (<whoosh.searching.Searcher object at 0x220e16d0>, 9295), (<whoosh.searching.Searcher object at 0x220e15d0>, 10295), (<whoosh.searching.Searcher object at 0x220e1610>, 11295), (<whoosh.searching.Searcher object at 0x220e1390>, 12295)]
        self
        <whoosh.searching.Collector object at 0x220e1ad0>
        t
        1335560310.119328
        /opt/python/domains/atlassian.com/answers/lib/python2.6/site-packages/whoosh/searching.py in add_matches
        return self.results()
        def add_matches(self, q, offset, scorefn):
        items = self.items
        limit = self.limit
        addall = self.should_add_all()
        for score, offsetid in self.pull_matches(q, offset, scorefn): ...
      3. Document numbers are negated before putting them in the heap so
      4. that higher document numbers have lower "priority" in the queue.
      5. Lower document numbers should always come before higher document
      6. numbers with the same score to keep the order stable.
        negated_offsetid = 0 - offsetid
        ▶ Local vars
        Variable Value
        addall
        False
        items
        []
        limit
        10
        offset
        24
        q
        And([Phrase('text', [u'confluenc', u'develop', u'document'], slop=1, boost=1.000000), Phrase(u'tags', [u'confluence-plugins', u'confluence-development'], slop=1, boost=1.000000)])
        scorefn
        None
        self
        <whoosh.searching.Collector object at 0x220e1ad0>
        /opt/python/domains/atlassian.com/answers/lib/python2.6/site-packages/whoosh/searching.py in pull_matches
        restrict = self.restrict
        replace = self.replace
        collect = self.collect
        minscore = self.minscore
        replacecounter = 0
        timelimited = bool(self.timelimit)
        matcher = q.matcher(self.subsearcher) ...
        usequality = self.use_block_quality(self.subsearcher, matcher)
        termlists = self.termlists
        recordterms = termlists is not None
        if recordterms:
        termmatchers = list(matcher.term_matchers())
        ▶ Local vars
        Variable Value
        allow
        None
        collect
        <bound method Collector.collect of <whoosh.searching.Collector object at 0x220e1ad0>>
        minscore
        None
        offset
        24
        q
        And([Phrase('text', [u'confluenc', u'develop', u'document'], slop=1, boost=1.000000), Phrase(u'tags', [u'confluence-plugins', u'confluence-development'], slop=1, boost=1.000000)])
        replace
        10
        replacecounter
        0
        restrict
        None
        scorefn
        None
        self
        <whoosh.searching.Collector object at 0x220e1ad0>
        timelimited
        False
        /opt/python/domains/atlassian.com/answers/lib/python2.6/site-packages/whoosh/query.py in matcher
        def estimate_size(self, ixreader):
        return min(q.estimate_size(ixreader) for q in self.subqueries)
        def matcher(self, searcher):
        r = searcher.reader()
        return self._matcher(IntersectionMatcher,
        lambda q: 0 - q.estimate_size(r), searcher) ...
        class Or(CompoundQuery):
        """Matches documents that match ANY of the subqueries.
        >>> Or([Term("content", u"render"),
        ▶ Local vars
        Variable Value
        r
        SegmentReader(<Segment '_MAIN_13' ccb20e95-5d7a-49f4-8f91-deda5fffc994>)
        searcher
        <whoosh.searching.Searcher object at 0x2aaab7b5f210>
        self
        And([Phrase('text', [u'confluenc', u'develop', u'document'], slop=1, boost=1.000000), Phrase(u'tags', [u'confluence-plugins', u'confluence-development'], slop=1, boost=1.000000)])
        /opt/python/domains/atlassian.com/answers/lib/python2.6/site-packages/whoosh/query.py in _matcher
      7. Create a matcher from the list of subqueries
        if len(subs) == 1:
        m = subs[0].matcher(searcher)
        elif q_weight_fn is None:
        subms = [q.matcher(searcher) for q in subs]
        m = make_binary_tree(matchercls, subms)
        else:
        subms = [(q_weight_fn(q), q.matcher(searcher)) for q in subs] ...
        m = make_weighted_tree(matchercls, subms)
      8. If there were queries inside Not(), make a matcher for them and
      9. wrap the matchers in an AndNotMatcher
        if nots:
        if len(nots) == 1:
        ▶ Local vars
        Variable Value
        _[2]
        [(-21, SpanNearMatcher(IntersectionMatcher(FilePostingReader('_MAIN_13.pst', ('text', u'confluenc'), True, 51), SpanNearMatcher(IntersectionMatcher(FilePostingReader('_MAIN_13.pst', ('text', u'develop'), True, 256), FilePostingReader('_MAIN_13.pst', ('text', u'document'), False)), boost=1.0)), boost=1.0))]
        kwargs
        {}
        matchercls
        <class 'whoosh.matching.IntersectionMatcher'>
        nots
        []
        q
        Phrase(u'tags', [u'confluence-plugins', u'confluence-development'], slop=1, boost=1.000000)
        q_weight_fn
        <function <lambda> at 0x22674f50>
        searcher
        <whoosh.searching.Searcher object at 0x2aaab7b5f210>
        self
        And([Phrase('text', [u'confluenc', u'develop', u'document'], slop=1, boost=1.000000), Phrase(u'tags', [u'confluence-plugins', u'confluence-development'], slop=1, boost=1.000000)])
        subs
        [Phrase('text', [u'confluenc', u'develop', u'document'], slop=1, boost=1.000000), Phrase(u'tags', [u'confluence-plugins', u'confluence-development'], slop=1, boost=1.000000)]
        /opt/python/domains/atlassian.com/answers/lib/python2.6/site-packages/whoosh/query.py in matcher
        for word in self.words:
        if (fieldname, word) not in reader:
        return NullMatcher()
        field = searcher.schema[fieldname]
        if not field.format or not field.format.supports("positions"):
        raise QueryError("Phrase search: %r field has no positions"
        % self.fieldname) ...
      10. Construct a tree of SpanNear queries representing the words in the
      11. phrase and return its matcher
        from whoosh.spans import SpanNear
        q = SpanNear.phrase(fieldname, self.words, slop=self.slop)
        m = q.matcher(searcher)
        ▶ Local vars
        Variable Value
        field
        KEYWORD(format=Frequency(boost=1.0), vector=None, scorable=True, stored=True, unique=False)
        fieldname
        u'tags'
        reader
        SegmentReader(<Segment '_MAIN_13' ccb20e95-5d7a-49f4-8f91-deda5fffc994>)
        searcher
        <whoosh.searching.Searcher object at 0x2aaab7b5f210>
        self
        Phrase(u'tags', [u'confluence-plugins', u'confluence-development'], slop=1, boost=1.000000)
        word
        u'confluence-development'

      Attachments

        Issue Links

          Activity

            People

              f85fd6c72783 eternicode
              jlargman Jeremy Largman
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: