scaliaes / sphinxsearch Goto Github PK
View Code? Open in Web Editor NEWSphinx Search for Laravel 4 (This package is unmaintained, for Laravel 5 support use https://github.com/sngrl/sphinxsearch )
Sphinx Search for Laravel 4 (This package is unmaintained, for Laravel 5 support use https://github.com/sngrl/sphinxsearch )
Hi.
I am trying to get search result excerpts working when using a modelname.
my search library function is as follows.
public static function objects($search,$orderBy, $order, $objectType,$deleted){
if ($search){
$results = SphinxSearch::search($search,'mainIndex')
->setMatchMode(\Sphinx\SphinxClient::SPH_MATCH_EXTENDED )
->SetRankingMode(\Sphinx\SphinxClient::SPH_RANK_SPH04)
->SetFieldWeights(
array(
'name' => 10,
'description' => 8
))
->filter('adjacencyId', array(0,Auth::user()->object_id),false)
->limit(1000);
Search::order($results,$orderBy,$order);
if(!isset($deleted)){
$results->filter('deleted',0);
}
if(isset($objectType)){
$results->filter('object_types_id', $objectType);
}
$result = $results->get(true);
$excerpt = $results->excerpt(current($result)->content); //<--- errors here
return $result;
}
}
i get the error "Document must be a string"
Is this possible?
Quick question: Is it best practice to use SphinxClient::escapeString() when passing user input? If so, I can't find a way to access this without making a - new \Sphinx\SphinxClient.
Hi. Is there anyway to use this library to fire off indexer commands?
Thanks!
Michael
I think this is a bug at least, i have sorting my data by most recent entries (date field). I got it working right, as soon as i put in the ->limit(200) my data is no longer the recent stuff. It loses its sorting. I can provide screenshots of the results if needed.
$results = SphinxSearch::search("pam_unix", "ninjalogs")
->setFieldWeights(array('devicereportedtime' => 10))
->limit(200)
->setMatchMode(\Sphinx\SphinxClient::SPH_MATCH_ANY)
->setSortMode(\Sphinx\SphinxClient::SPH_SORT_ATTR_DESC, 'devicereportedtime')
->get(true);
I temporarily added this line to sphinxsearch.php and took out my ->limit(200) and it worked properly.
$this->_connection->setLimits(0, 200, 200, 0);
I am not sure why its not taking the 200 and using it properly.
Any ideas?
Hi,
I just wanna search based on geo distance from a certain coordinate, but without any query keyword. I've tried using empty string and null but they always match nothing. When I give it some keyword, it works fine.
Can I achieve that with Sphinx? Or any other idea?
Thank you.
Can we have Laravel 5 support for this package?
Hi.
I am looking at the code and can see that filters only work on numeric values.
i would like to help add support for text. do you recon:
I will play but wanted to know if you had a preferance to code flow etc..
many thanks
calvin streeting
The author whether to increase support for laravel5 ?
i had to change line 60 to
$val = $values;
form
$val = [(int) $values];
in scalia/sphinxsearch/src/Scalia/SphinxSearch/SphinxSearch.php
not sure if my system (aka missing something silly)
many thanks...
calvin
Thank you for this great package!
I am developing a wep application that has articles and career ads. I have two search form, 1 for articles and 1 for career ads.
I want to search for careers only, no results from the articles index.
How should I do that in the config?
It'd be great if theres an example...
I'm stumped trying to figure out how to use elasticsearch.
Can you please add the following method to your package? I tried extending it but the $_connection property is "private".
function setMatchMode($mode)
{
$this->_connection->setMatchMode($mode);
return $this;
}
Hello!
Could you help me please with this issue?
I'v got 2 indexes: offers and products. Below you can look through some of my config: https://gist.github.com/AleksMeshkov/9738763
So how can I perform a search with this 2 indexes simultaneously? How should I setup my sphinx search config? (https://gist.github.com/AleksMeshkov/9738879)
Yep, I saw https://github.com/scalia/sphinxsearch#searching-through-multiple-sphinx-indexes-maindelta But I can't apply that in my case.
Thank's in advance!
hi..
i altered the get function to work with Eloquents withTrashed option (added as an option to get..)
many thanks
calvin
...
public function get($respect_sort_order = false,$withTrashed = false)
{
$this->_total_count = 0;
$result = $this->_connection->query($this->_search_string, $this->_index_name);
// Process results.
if ($result)
{
// Get total count of existing results.
$this->_total_count = (int) $result['total_found'];
// Get time taken for search.
$this->_time = $result['time'];
if($result['total'] && isset($result['matches']))
{
// Get results' id's and query the database.
$matchids = array_keys($result['matches']);
$idString = implode(',', $matchids);
$config = isset($this->_config['mapping']) ? $this->_config['mapping'] : $this->_config[$this->_index_name];
if ($config)
{
if (isset($config['modelname']))
{
if ($this->_eager_loads) {
if ($withTrashed) {
$result = call_user_func_array($config['modelname'] . "::whereIn", array($config['column'], $matchids))->orderByRaw(\DB::raw("FIELD(id, $idString)"))->withTrashed()->with($this->_eager_loads)->get();
}
else {
$result = call_user_func_array($config['modelname'] . "::whereIn", array($config['column'], $matchids))->orderByRaw(\DB::raw("FIELD(id, $idString)"))->with($this->_eager_loads)->get();
}
} else {
if ($withTrashed) {
$result = call_user_func_array($config['modelname'] . "::whereIn", array($config['column'], $matchids))->orderByRaw(\DB::raw("FIELD(id, $idString)"))->withTrashed()->get();
}
else {
$result = call_user_func_array($config['modelname'] . "::whereIn", array($config['column'], $matchids))->orderByRaw(\DB::raw("FIELD(id, $idString)"))->get();
}
}
}
else
{
$result = \DB::table($config['table'])->whereIn($config['column'], $matchids)->orderByRaw(\DB::raw("FIELD(id, $idString)"))->get();
}
}
}
else
{
$result = array();
}
}
....
Hi ,
Please remove int casting from filter function line 102 and 107
In my case i need to filter by string value , as you know it's impossible in the sphinx so i creating numeric checksum value
Please look for example in
http://stackoverflow.com/questions/5736037/create-a-filter-in-sphinx-with-text-string-value
function
public static function crc32($val){
$checksum = crc32($val);
if($checksum < 0) $checksum += 4294967296;
return $checksum;
}
But there is some issue in windows 64 bit and PHP with integer size (Mysql work as expected) .
Because of the int issue in windows some time i receiving negative value from crc32 and then i add 4294967296 to return value to convert it back to positive integer in some cases the result is double type (again because integer issue in windows) and then the cast to int return checksum back to negative value and fake the search result.
return array (
'host' => '127.0.0.1',
'port' => 9312,
'indexes' => array (
'my_index_name' => array ( 'table' => '???', 'column' => '??' ),
)
);
$results = SphinxSearch::search('?', '?')
->limit(30)
->filter('?', ?)
->range('?', ?)
->get();
what are where you insert?
How it works?
Is it possible to use non-default DB settings for querying my Sphinx DB? I'd like to store my Sphinx records in a completely separate database than my main Laravel site, but it looks like this isn't supported by SphinxSearch. Maybe I'm missing something? If not, are there any plans to add support for this feature?
Current version depends on dev-master of gigablah/sphinxphp.
I believe it is a bad practice to rely on dev-master version anyway, however, this dependency also breaks the simple composer installation, as the default minimum-stability is "stable".
Thank you for a great package! I have a feature request.
When searching an eloquent model it looks like the following query is executed behind the scenes:
ModelName::whereIn('id_column', $matchIds)
It would be nice to be able to specify some eager loads so that the query would become:
ModelName::with(['relationship1','relationship2','etc'])->whereIn('id_column',$matchIds)
With something like:
$results = SphinxSearch::search($query)->with(['relationship1','relationship2','etc'])->get(true);
My current workaround is to manually run the second query on the eloquent model.
Is there a way to highlight words within documents that met criteria?
http://stackoverflow.com/questions/26463390/get-excerpt-around-search-word
I got this working, its pretty sweet. I am just figuring out sphinx and my table i point the sphinxsearch at is constantly removing and adding entries. Using this with laravel i can specify an index. Do i need to run the indexer for sphinx? or is that separate? For you guys that know sphinx, will sphinxsearch work for this kind of environment? thanks i wish github had a messaging system instead of making an issue to talk to the maintainers/devs.
This code works fine except results not sorted at all:
$results = SphinxSearch::search($search, $indexName)
->setFieldWeights(
$weights
)
->setMatchMode(\Sphinx\SphinxClient::SPH_MATCH_EXTENDED)
->setSortMode(\Sphinx\SphinxClient::SPH_SORT_EXTENDED, "@weight DESC")
->get();
But if I'm making
->get(true);
then I'm getting error Trying to get property of non-object
in laravel.site/vendor/scalia/sphinxsearch/src/Scalia/SphinxSearch/SphinxSearch.php
in line 250:
if ( $result_item->id == $id )
(this is function getResultKeyByID($id, $result)
)
Assume the following line
$result = SphinxSearch::search(Input::get('query'))->get();
(where the underlying model is called Product). If in the Product name you have a dynamic attribute set with getXXXAttribute() such as $product->final_price (which would be created via a getFinalPriceAttribute() method), then that attribute will NOT be created for that object. That is, $product->final_price will not exist for results returned from SphinxSearch. I'm running the latest dev-master.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.