-
Notifications
You must be signed in to change notification settings - Fork 33
Changed SphinxSearchBundle->search() to match API #5
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
base: master
Are you sure you want to change the base?
Conversation
|
I've been thinking about this lately. I agree that the current implementation of The problem that I have with changing how it works is how the query options are passed in. The readme has the following example: $indexesToSearch = array(
'Items' => array(
'result_offset' => 0,
'result_limit' => 25,
'field_weights' => array(
'Name' => 2,
'SKU' => 3,
),
),
'Categories' => array(
'result_offset' => 0,
'result_limit' => 10,
),
);
$sphinxSearch = $this->get('search.sphinxsearch.search');
$searchResults = $sphinxSearch->search('search query', $indexesToSearch);That works, because each listed index is queried independently of the other indexes. If I think the best solution would be to specify the options for the query, as opposed to for each index. Something like this: $indexesToSearch = array(
'Items',
'Categories',
);
$queryOptions = array(
'result_offset' => 0,
'result_limit' => 25,
);
$sphinxSearch = $this->get('search.sphinxsearch.search');
$searchResults = $sphinxSearch->search('search query', $indexesToSearch, $queryOptions);Any thoughts? |
|
I agree with the above, passing options for the query makes sense. My orignal fix was more intended to get me past a problem more than be an absolutely perfect solution. Happy to help out implementing this if you like. Ps thanks for creating this bundle in the first place. Save me lots of time integrating sphinx with our Symfony2 based apps. |
|
+1 for pull request |
|
I have add another commit to this pull which adds more advanced api calls the bundle in addQuery, resetAllFilters, and runQueries. This allows you to setup a batch of queries with different filters and pass them all to searchd at once to be run. |
Sorry, had wrong commits attached to previous pull...
I have changed the search function to match the intended SphinxAPI behavior.
Previously when you searched multiple indexes with:
$indexes = array(
'All_Items' => array(
'result_offset' => 0,
'result_limit' => 1000
),
'All_Items_Delta' => array(
'result_offset' => 0,
'result_limit' => 1000
)
);
$result = $sphinxsearch->search($search_str,$indexes);
It executed SphinxAPI->query() once for each index and saved the results to a named array. This means advanced functionality like kill-lists do not work.
I have changed it so it now executes SphinxAPI->query() once with both indexes and my kill-list now works as intended which means I can have a delta index of updates and a full index but, not have results from the full index returned if that document exists in delta index (the delta being the latest version).
If someone wanted to execute a search on two different indexes independently I would expect they run SphinxSearchBundle->search() twice.
Anyhow fix my problem, not sure if you want to include it in the bundle.
Additionally I changed the sphinxsearch.xml so that bundle worked when installed to vendors/bundles/Search/SphinxSearch/ which I think would be the conventional location for the 3rd party bundle in the Symfony2 framework.
Cheers for all your hard work, made it much easier for me to integrate Sphinx and Symfony2 thats for sure!