Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
About SphinxsearchBundle
========================



Installation:
-------------

Expand All @@ -11,7 +9,19 @@ Installation:

### Step 1: Download the bundle

How you actually download the bundle is entirely up to you. The easiest way is to grab it from [packagist.org](http://packagist.org/).
How you actually download the bundle is entirely up to you. Since I'm not sure how much time I'll be able to spend maintaining this bundle, I've opted to keep it as a VCS bundle for now and not put it on packagist. This may change in the future if there is enough interest. The relevant portions of composer.json are:

``` JSON
"repositories": [
{
"type": "vcs",
"url": "[email protected]:spreston/Search-SphinxsearchBundle.git"
}
],
"require": {
"search/sphinxsearch-bundle": "dev-master",
}
```

### Step 2: Configure the bundle

Expand All @@ -30,7 +40,7 @@ sphinxsearch:

At least one index must be defined, and you may define as many as you like.

In the above sample configuration, `Categories` is used as a label for the index named `%sphinxsearch_index_categories%` (as defined in your `sphinxsearch.conf`). This allows you to avoid having to hard code raw index names inside of your code.
In the above sample configuration, `Categories` is used as a label for the index named `%sphinxsearch_index_categories%` (as defined in your `sphinxsearch.conf`). This allows you to avoid having to hard code raw index names inside of your configuration.



Expand All @@ -54,6 +64,7 @@ $indexesToSearch = array('Items');
$options = array(
'result_offset' => 0,
'result_limit' => 25,
'ignore_warnings' => true,
'field_weights' => array(
'Name' => 2,
'SKU' => 3,
Expand All @@ -65,15 +76,17 @@ $sphinxSearch->setFilter('disabled', array(1), true);
$searchResults = $sphinxSearch->search('search query', $indexesToSearch, $options);
```

This would again search `Items` for `search query`, but now it will only return up to the first 25 matches and weight the `Name` and `SKU` fields higher than normal. Note that in order to define a `result_offset` or a `result_limit`, you must explicitly define both values. Also, this search will use [the Extended query syntax](http://sphinxsearch.com/docs/current.html#extended-syntax), and exclude all results with a `disabled` attribute set to 1.
This would again search `Items` for `search query`, but now it will only return up to the first 25 matches and weight the `Name` and `SKU` fields higher than normal. Note that in order to define a `result_offset` or a `result_limit`, you must explicitly define both values. Also, this search will use [the Extended query syntax](http://sphinxsearch.com/docs/current.html#extended-syntax), and exclude all results with a `disabled` attribute set to 1. The ignore_warnings option is recommended if you plan on using the @@relaxed option, as it returns a warning when non-existent fields are referenced.



License:
--------

```
Copyright (c) 2012, Ryan Rogers
Copyright (c)
2012, Ryan Rogers
2014, Steve Preston
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
8 changes: 7 additions & 1 deletion Services/Search/Sphinxsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,13 @@ public function search($query, array $indexes, array $options = array(), $escape
* Perform the query.
*/
$results = $this->sphinx->query($query, $indexNames);
if( $results['status'] !== SEARCHD_OK )

/**
* If status is not ok and status is not ignored warning
* This is required for '@@relaxed' to work correctly since it returns a warning on non-existent fields
*/
if( $results['status'] !== SEARCHD_OK &&
!($results['status'] == SEARCHD_WARNING && isset($options['ignore_warnings']) && $options['ignore_warnings']) )
throw new \RuntimeException(sprintf('Searching index "%s" for "%s" failed with error "%s".', $label, $query, $this->sphinx->getLastError()));

return $results;
Expand Down
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"name": "search/sphinxsearch-bundle",
"type": "symfony-bundle",
"description": "Sphinx search bundle for Symfony 2",
"description": "Sphinx search bundle for Symfony 2. Forked from https://github.com/timewasted/Search-SphinxsearchBundle",
"keywords": ["sphinx", "sphinxsearch", "symfony2"],
"homepage": "https://github.com/timewasted/Search-SphinxsearchBundle",
"homepage": "https://github.com/spreston/Search-SphinxsearchBundle",
"license": "BSD-2-Clause",
"authors": [
{
"name": "Steve Preston",
"email": "[email protected]"
},
{
"name": "Ryan Rogers",
"email": "[email protected]"
Expand Down