Skip to content

Wrong result in AND query #28

Closed
Closed

Description

@amallia

I created an index with a single document: FT.ADD myIdx doc1 1.0 FIELDS title "hello world" body "lorem ipsum" url "http://redis.io".
From my understanding of query syntax documentation the following queries should have the same meaning:

  • FT.SEARCH myIdx test ipsum LIMIT 0 1
  • FT.SEARCH myIdx ipsum test LIMIT 0 1
    They both should return the intersection of test AND ipsum.

Apparently the result set is empty for the first query (correct), while doc1 is returned for the second query (wrong).

Is this an expected behaviour?

Activity

  1. changed the title [-]Wrong result is AND query[/-] [+]Wrong result in AND query[/+] on Mar 2, 2017
  2. dvirsky commented on Mar 2, 2017

    @dvirsky
    Contributor

    Hey @amallia! you need to put the terms in quotes, otherwise the redis protocol interprets them as two different arguments. Basically you performed two single term queries. You should do:

    FT.SEARCH myIdx "test ipsum" LIMIT 0 1
    FT.SEARCH myIdx "ipsum test" LIMIT 0 1
    

    I recommend using the Python or Java libraries for abstraction.
    https://github.com/RedisLabs/redisearch-py
    https://github.com/RedisLabs/JRediSearch

  3. dvirsky commented on Mar 2, 2017

    @dvirsky
    Contributor

    (once you've verified this is indeed not a bug, please close this issue. thanks!)

  4. amallia commented on Mar 3, 2017

    @amallia
    ContributorAuthor

    Yes, you are right. I thought double quotes was for exact search, but in that case I need to quote twice like FT.SEARCH myIdx '"ipsum lorem"' LIMIT 0 1

  5. dvirsky commented on Mar 3, 2017

    @dvirsky
    Contributor

    yes, you can also do FT.SEARCH myIdx "\"ipsum lorem\"" LIMIT 0 1. Of course in client libraries all this is abstracted away, and it only applies to redis-cli.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions