-
Notifications
You must be signed in to change notification settings - Fork 57
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
feat: search_fields #407
base: main
Are you sure you want to change the base?
feat: search_fields #407
Conversation
allow for more specific search queries by specifying the search_operator
allow for more specific search queries by specifying the search_fields. TODO: My searchFields tests don't seem to be working quite the way I'd like. I tried setting up a body field to specify alongside title, but it didn't work. At first I didn't realize why. In my customized grapple implementation, I use my own custom page type as the root for all queries rather the wagtail.model.Page that has all my common search_fields... I'm realizing that doesn't work with grapple atm as you can't specify an alternate root model. Where grapple uses a [mixin with qs=WagtailPageObjects.all()](https://github.com/torchbox/wagtail-grapple/blob/0d20a8cd8de6cceb260a1ade564effa6c2db1e79/grapple/types/pages.py#L377), I use standalone function that looks like ``` def _resolve_search_pages( info, content_types=[], page=1, per_page=10, root=TnPage.objects.live().specific(), categories=[], tags=[], ancestor=None, parent=None, in_menu=None, **kwargs ): """ root allows an alternative queryset to be passed in to allow for inheriting types to filter the queryset first. """ ``` I need to resolve this issue before this will be usable to end users... possible solutions... 1. pass a 'root' into PagesQuery to overide the base model for pages and add a way to specify the root model. 2. find a way to get this to work with .get_specific_page I don't have any other ideas at the moment.
fa48a6f
to
64475f2
Compare
I did some additional experimenting with the testapp today. Next steps are to test query blogPages directly after specifying body as a search field on blogPages to see if that works... If it does huzzah there is some value here that may be worth merging with proper documentation... otherwise I need to proceed with figuring out the alternate root or get specific pages issue |
So the issue with search fields applying across different page models is that we work with the bas Page class, and even if we did specific, you can't do a simple "search across these fields" in that we need construct an OR query for each page type that has the given fields. It should work for the specific ones like |
I believe that is the issue. I need to get around to verifying it and writing the tests for it. |
My searchFields tests don't seem to be working quite the way I'd like. I tried setting up a body field to specify alongside title, but it didn't work. At first I didn't realize why. In my customized grapple implementation, I use my own custom page type as the root for all queries rather the wagtail.model.Page that has all my common search_fields... I'm realizing that doesn't work with grapple atm as you can't specify an alternate root model. Where grapple uses a mixin with qs=WagtailPageObjects.all(), I use standalone function that looks like
I need to resolve this issue before this will be usable to end users... possible solutions...
I don't have any other ideas at the moment.