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 statement functionality #2

Open
netfl0 opened this issue Apr 4, 2012 · 6 comments
Open

LIMIT statement functionality #2

netfl0 opened this issue Apr 4, 2012 · 6 comments

Comments

@netfl0
Copy link

netfl0 commented Apr 4, 2012

The default sphinx configuration returns 20 results, it would be nice to be able to configure that from django methods on the fly.

something like:

MyIndex.objects.filter(content__serach, limit=40)

I was thinking something similar for the offset functionality, but I don't know if the RT indexes support that yet.

@btimby
Copy link
Contributor

btimby commented Apr 4, 2012

Peter, this is a good idea. I am not sure of the details at this time
either. I know that typically Django uses slicing to define limits.

MyIndex.objects.filter(content__search='keyword')[:20]

Would limit to the first 20 results. This could be added to the Sphinx backend.

MyIndex.objects.filter(content__search='keyword')[20:40]

The above would start at 20, and return 40 records.

@netfl0
Copy link
Author

netfl0 commented Apr 4, 2012

I learned something new here :)

getitem() and slice objects

I think your recommended implementation is elegant. I have a lot of
ideas for features, should I open up a bunch of separate tickets?

@btimby
Copy link
Contributor

btimby commented Apr 4, 2012

Please do.

@btimby
Copy link
Contributor

btimby commented Apr 6, 2012

Apparently Sphinx does not support the OFFSET keyword. This is what is used to perform a query that starts at a particular index, therefore the following is not valid:

MyIndexModel.objects.all()[1:2]

But, this is valid:

MyIndexModel.objects.all()[:2]

It would be nice if Sphinx supported OFFSET in addition to LIMIT, however, we can probably do some hackery to emulate it in the SphinxSQLCompiler. More research is needed.

@btimby
Copy link
Contributor

btimby commented Apr 9, 2012

Opened issue upstream.

http://sphinxsearch.com/bugs/view.php?id=1154

@dbrgn
Copy link
Contributor

dbrgn commented Jul 17, 2012

In the meantime, could you add simple LIMIT functionality?

Also, I think django-sphinx-db should return max_matches items by default, not 20. If people want, they can still limit it using slicing, but otherwise it will confuse people.

jnormore pushed a commit to jnormore/django-sphinx-db that referenced this issue Jun 14, 2014
SQR-5028 еще один фикс связанный с претставление текста запроса SphinxQu...
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

3 participants