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

LIMIT for NUMERIC fields not working #61

Closed
onexdrk opened this issue Jun 1, 2017 · 9 comments
Closed

LIMIT for NUMERIC fields not working #61

onexdrk opened this issue Jun 1, 2017 · 9 comments
Labels

Comments

@onexdrk
Copy link

onexdrk commented Jun 1, 2017

steps to reproduce

  1. prepare data
FT.CREATE testidx SCHEMA num NUMERIC name TEXT
FT.ADD testidx doc1 1 FIELDS num 140 name test
FT.ADD testidx doc2 1 FIELDS num 1400 name test
FT.ADD testidx doc3 1 FIELDS num 1405 name test
  1. check with 2 records
 FT.SEARCH testidx "@num:[0 1000000]" LIMIT 0 2
return: doc1, doc3
 FT.SEARCH testidx "@num:[0 1000000]" LIMIT 1 2
return: doc2, doc3
 FT.SEARCH testidx "@num:[0 1000000]" LIMIT 2 2
return: doc2, doc3
  1. check with 1 record
 FT.SEARCH testidx "@num:[0 1000000]" LIMIT 0 1
return: doc3
 FT.SEARCH testidx "@num:[0 1000000]" LIMIT 0 1
return: doc3
@dvirsky
Copy link
Contributor

dvirsky commented Jun 6, 2017

This is unrelated to numeric indexes, but a bug in paging when there are less results than 10. Will be fixed, thanks for catching this.

@dvirsky dvirsky added the c:bug label Jun 6, 2017
@dvirsky dvirsky self-assigned this Jun 6, 2017
@dvirsky
Copy link
Contributor

dvirsky commented Jun 7, 2017

Okay, it's not actually what happens. The problem is that all documents have the same score so the compare function was unstable. I've changed it a bit and it seems to be working better.

If you want to sort by the numeric property, take a look at sortable properties and the SORTBY argument in the docs. http://redisearch.io/Sorting/

@dvirsky dvirsky closed this as completed Jun 7, 2017
@onexdrk
Copy link
Author

onexdrk commented Jun 7, 2017

Got it, thanks. Is it already in master?

@dvirsky
Copy link
Contributor

dvirsky commented Jun 7, 2017

yes

@onexdrk
Copy link
Author

onexdrk commented Jun 7, 2017

Excuse me, but seems that i have another kind of problem. Imagine i want to organize paging functionality with page-size = 4

create an index and add five documents to it:

FT.CREATE indexName SCHEMA status TEXT

FT.ADD indexName doc1 1 FIELDS status open
FT.ADD indexName doc2 1 FIELDS status open
FT.ADD indexName doc3 1 FIELDS status open
FT.ADD indexName doc4 1 FIELDS status open
FT.ADD indexName doc5 1 FIELDS status open

Then i want to get first page with 4 elements in it:

FT.SEARCH indexName "@status:open" LIMIT 0 4
1) (integer) 5
2) "doc5"
3) 1) "status"
   2) "open"
4) "doc4"
5) 1) "status"
   2) "open"
6) "doc3"
7) 1) "status"
   2) "open"
8) "doc2"
9) 1) "status"
   2) "open"

response correct

Now i want go see last element:

FT.SEARCH indexName "@status:open" LIMIT 4 4
1) (integer) 5
2) "doc4"
3) 1) "status"
   2) "open"
4) "doc3"
5) 1) "status"
   2) "open"
6) "doc2"
7) 1) "status"
   2) "open"
8) "doc1"
9) 1) "status"
   2) "open"

Incorrect - must contains only doc1.

I think i can try fix it in backend and if it is last page - trim result and use just a tail, but it looks like a problem

@dvirsky
Copy link
Contributor

dvirsky commented Jun 7, 2017

The semantics are LIMIT {offset} {num} with a zero based index, so the 4th element should be accessed with LIMIT 3 1. However, this is in fact a bug, you are right.

@onexdrk
Copy link
Author

onexdrk commented Jun 7, 2017

Please, let me know if it will be fixed. May be open new issue about that?

@dvirsky
Copy link
Contributor

dvirsky commented Jun 7, 2017

Yes, I prefer another issue if you don't mind.

@onexdrk
Copy link
Author

onexdrk commented Jun 7, 2017

Yep, thanks, I'll create it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants