Two searches in one roundtrip?
Hi,
I'm not really expecting a positive answer for this one, but just in case a solution happens to exist:
To reduce load times, I'm wondering if there might be a way of performing two separate searches in one round trip?
Background
I'm working on adding some extra ad entries to the top of our search results, somewhat like Google does, and these should actually come from a subset of the data we are already searching. I'm currently fetching the ad results using an extra ThinkingSphinx.search call, on the same index, with some additional filtering to find the "advertisable" entries.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Pat Allan on 20 Mar, 2018 12:37 PM
Hi Roger,
It is indeed possible to send two search queries in a single call to Sphinx. Presuming you're using TS v3, this syntax should do the trick:
Keep in mind that if you're testing this in a Rails console, the inspection of a search results set populates the data immediately, which would make this fail. An easy way around this is to add
; ""
at the end of lines that involve search calls. e.g.:All of that said… if you need the values from the first search to be used in the second, I'm afraid that's not possible in Sphinx.
2 Posted by roger on 20 Mar, 2018 12:48 PM
Hey, that's awesome. Can't believe I didn't stumble across this when googling.
Thanks, Pat!
Support Staff 3 Posted by Pat Allan on 20 Mar, 2018 01:09 PM
Mostly it's not documented, and it's rarely requested, so it would have taken quite some googling!
Though I've realised it's not in the documentation at all - and I've been working on that for the upcoming v4 release, so I'll make sure it gets added shortly.