Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SearchAPI - OR query returns all documents #2938

Open
scragraham opened this issue Dec 14, 2018 · 0 comments
Open

SearchAPI - OR query returns all documents #2938

scragraham opened this issue Dec 14, 2018 · 0 comments

Comments

@scragraham
Copy link
Contributor

Summary
When running a query with the OR operator, the search results return all documents instead of the two expected.

Steps to Reproduce
Input documents:

      json={"index": "index-1", "documents": [
        { 
          "id": "a",
          "text1": "hello world",
          "text2": "testing search api and world"
        },
        { 
          "id": "b",
          "anotherText": "There is also a corresponding asynchronous method, "
        },
        { 
          "id": "c",
          "text3": "This string also contains the word world and api"
        },
        { 
          "id": "firstdate",
          "date_entered": "2018-12-12",
          "text4": "This is a test of the national broadcasting system"
        },
        { 
          "id": "seconddate",
          "date_entered": "2019-04-04",
          "text5": "Who are the britons?"
        }
      ]}

Unittest:

  def test_search_query_OR(self):
    response = self.app.post(
      '/python/search/search',
      json={"index": "index-1", "query": "hello OR britons"})

    self.assertEquals(response.status_code, 200)
    self.assertIn('documents', response.json())
    documents = response.json()['documents']
    self.assertEquals(len(documents), 2)

Expected Results
2 documents: id: a, id: seconddate

Actual Results
all 5 documents.

Debug Logging from /var/log/appscale/search.log

2018-12-14 22:22:23,085 DEBUG solr_interface.py:333 Solr results: {'responseHeader': {'status': 0, 'QTime': 2, 'params': {'defType': 'edismax', 'rows': '20', 'q': '_gaeindex_name:hawkeyepython27__index-1 AND  AND (%22hello%22 OR%22britons%22)', 'start': '0', 'wt': 'json', 'pf': 'hawkeyepython27__index-1_anotherText hawkeyepython27__index-1_date_entered hawkeyepython27__index-1_text1 hawkeyepython27__index-1_text2 hawkeyepython27__index-1_text3 hawkeyepython27__index-1_text4 hawkeyepython27__index-1_text5', 'qf': 'hawkeyepython27__index-1_anotherText hawkeyepython27__index-1_date_entered hawkeyepython27__index-1_text1 hawkeyepython27__index-1_text2 hawkeyepython27__index-1_text3 hawkeyepython27__index-1_text4 hawkeyepython27__index-1_text5', 'fl': 'id _gaeindex_locale hawkeyepython27__index-1_anotherText hawkeyepython27__index-1_date_entered hawkeyepython27__index-1_text1 hawkeyepython27__index-1_text2 hawkeyepython27__index-1_text3 hawkeyepython27__index-1_text4 hawkeyepython27__index-1_text5'}}, 'response': {'start': 0, 'numFound': 5, 'docs': [{'_gaeindex_locale': ['en'], 'id': 'a', 'hawkeyepython27__index-1_text1': 'hello world', 'hawkeyepython27__index-1_text2': 'testing search api and world'}, {'_gaeindex_locale': ['en'], 'id': 'b', 'hawkeyepython27__index-1_anotherText': 'There is also a corresponding asynchronous method, '}, {'_gaeindex_locale': ['en'], 'hawkeyepython27__index-1_text3': 'This string also contains the word world and api', 'id': 'c'}, {'_gaeindex_locale': ['en'], 'hawkeyepython27__index-1_text4': 'This is a test of the national broadcasting system', 'id': 'firstdate', 'hawkeyepython27__index-1_date_entered': '2018-12-12'}, {'_gaeindex_locale': ['en'], 'hawkeyepython27__index-1_text5': 'Who are the britons?', 'id': 'seconddate', 'hawkeyepython27__index-1_date_entered': '2019-04-04'}]}}

Pretty printed:

{
    "response": {
        "docs": [
            {
                "_gaeindex_locale": [
                    "en"
                ],
                "hawkeyepython27__index-1_text1": "hello world",
                "hawkeyepython27__index-1_text2": "testing search api and world",
                "id": "a"
            },
            {
                "_gaeindex_locale": [
                    "en"
                ],
                "hawkeyepython27__index-1_anotherText": "There is also a corresponding asynchronous method, ",
                "id": "b"
            },
            {
                "_gaeindex_locale": [
                    "en"
                ],
                "hawkeyepython27__index-1_text3": "This string also contains the word world and api",
                "id": "c"
            },
            {
                "_gaeindex_locale": [
                    "en"
                ],
                "hawkeyepython27__index-1_date_entered": "2018-12-12",
                "hawkeyepython27__index-1_text4": "This is a test of the national broadcasting system",
                "id": "firstdate"
            },
            {
                "_gaeindex_locale": [
                    "en"
                ],
                "hawkeyepython27__index-1_date_entered": "2019-04-04",
                "hawkeyepython27__index-1_text5": "Who are the britons?",
                "id": "seconddate"
            }
        ],
        "numFound": 5,
        "start": 0
    },
    "responseHeader": {
        "QTime": 2,
        "params": {
            "defType": "edismax",
            "fl": "id _gaeindex_locale hawkeyepython27__index-1_anotherText hawkeyepython27__index-1_date_entered hawkeyepython27__index-1_text1 hawkeyepython27__index-1_text2 hawkeyepython27__index-1_text3 hawkeyepython27__index-1_text4 hawkeyepython27__index-1_text5",
            "pf": "hawkeyepython27__index-1_anotherText hawkeyepython27__index-1_date_entered hawkeyepython27__index-1_text1 hawkeyepython27__index-1_text2 hawkeyepython27__index-1_text3 hawkeyepython27__index-1_text4 hawkeyepython27__index-1_text5",
            "q": "_gaeindex_name:hawkeyepython27__index-1 AND  AND (%22hello%22 OR%22britons%22)",
            "qf": "hawkeyepython27__index-1_anotherText hawkeyepython27__index-1_date_entered hawkeyepython27__index-1_text1 hawkeyepython27__index-1_text2 hawkeyepython27__index-1_text3 hawkeyepython27__index-1_text4 hawkeyepython27__index-1_text5",
            "rows": "20",
            "start": "0",
            "wt": "json"
        },
        "status": 0
    }
}

The query to solr seems a bit off:

"q": "_gaeindex_name:hawkeyepython27__index-1 AND  AND (%22hello%22 OR%22britons%22)",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant