I am new to Redissearch-php , i want performs query search on redis with redis search engine (php). i have tried example from this link : http://www.ethanhann.com/redisearch-php/searching/, but its always returning empty array,
Please find code example here,
$document = $bookIndex->makeDocument();
$document->title->setValue('How to be awesome.');
$document->author->setValue('Jack');
$document->price->setValue(9.99);
$document->stock->setValue(9);
$bookIndex->add($document);
return $bookIndex->search('How')->getCount();
Can someone tell me, what i am doing wrong here ?
Related
In my website I need to customise the url ,
I done it some way ,everything is working fine .I got what I need ,but I want to do it in a proper way .
Below is my code
$route['admin/lessons'] = 'admin/admin/lessons';
$route['admin/lesson_mgmt'] = 'admin/admin/lesson_mgmt';
$route['admin/labs'] = 'admin/admin/labs';
$route['admin/tools'] = 'admin/admin/tools';
Here in this way I am managing the custom url section .
I want to make this url dynamic so that ,the code will not be longer ,there are other section .
If i will do it in this way ,I have to write a lot .
Here i want to replace everything in a single line.
Can anyone suggest me anything ?
Thank you in advance.
Try like this...
In your application/config/routes.php
$route['admin/([a-zA-Z0-9_-]+)'] = 'admin/admin/$1';
Hope it will work fine..
In above code.. [a-zA-Z0-9_-]+) this is regular expression having combination of one or more alphanumeric characters(alphabets+numbers).If route gets admin/characters...it redirect to admin/admin/characters.
So I have a php script on a web server listening for mongoDB queries via a JSON object POST with another page building and sending queries to the php service. All my standard queries such as :
{"field1":"2342342","field2":"234234"} are sent and return the correct resutls.
However, when I try to send a query that includes a range of values it returns nothing.
{"field2":"1234","date" : {$gte : "2013-02-11"},"date" : {$lte : "2013-02-11"}}
I can go into the command line and call:
db.collection.find({"field2":"1234","date" : {$gte : "2013-02-11"},"date" : {$lte : "2013-02-11"}} )
which returns the results as expected. Obviously there is something going on that I do not fully understand.
PHP command doing the search:
$c_collection->find(json_decode($request));
Any help would be much appreciated.
You are attempting to search the database using a duplicate element name. MongoDb would issue an error such as this while performing this search:
Duplicate element name 'date'.
You need to place your range within the same block. For example:
{
'date': {
$gte:"datehere",
$lte:"datehere"
}
}
In PHP:
$criteria = array('date' => array('$gte' => 'datehere', '$lte' => 'datehere'));
Then use that json as your criteria.
Also, why are you decoding the criteria before passing it to the database? The method can accept an array just fine.
I searched here, but couldn't find solution to my problem.
I was trying to use the example code, Simple Subgrid worked fine.
However, Subgrid 2 Level is not working.
displaygrid.php contains:
$grid->setSubGridGrid("displaysubgrid.php");
when I try to have the following code in displaysubgrid.php
$grid->querySubGrid(array(&$rowid));
I get output like
{"rows":[{"stockNumber":"LOT1","stock":"5","expiration":"2013-01-01"}]}
Which means data passing is okay. However, when I try to use the following
$subtable = $subtable."_t";
$pager = $subtable."_p";
$grid->renderGrid($subtable,$pager, true, null, array(&$rowid), true,true);
it's showing empty grid!
How get google search results url?
(I use Zend_Gdata_Gbase for get search google results and not DomDocument/htmlsimpleparser because its looks to me that Zend_Gdata_Gbase done specially for parsing google results.
if I wrong in my selection, please write.)
My function to get google search results for 'yahoo' or other query search string:
(the function get a feed that should have search result for word 'yahoo', but when i use prin_t($feed) I don't see url for each result)
<?php
function queryGoogleSearch($queryString='yahoo'){
$service = new Zend_Gdata_Gbase();
$query = $service->newSnippetQuery();
$query->setBq('['.$queryString.']');
$query->setOrderBy('modification_time');
$query->setSortOrder('descending');
$query->setMaxResults('4');
$feed = $service->getGbaseSnippetFeed($query);
return $feed;
}
print_r(queryGoogleSearch());
?>
I get 4 first url results (when I search manually in google):
www.yahoo.com, mail.yahoo.com, search.yahoo.com, maps.yahoo.com
But I can't find them when I print $feed variable.
Please what should i change or add inqueryGoogleSearch() function? (Or other better code)
Thanks
Are you trying to search google.com. Looks like that class is for Google Base, not google.com search engine. http://base.google.com/support/bin/answer.py?hl=en&answer=59260
You probably want this: http://code.google.com/apis/customsearch/v1/overview.html
They recently just changed this. The old google search API has now deprecated as of Nov 1st. Custom search is the new API.
Its pretty simple to use without Zend.
http://code.google.com/apis/customsearch/v1/using_rest.html#WorkingResults
There is a JSON decoder in PHP.
http://php.net/manual/en/function.json-decode.php
Hope that helps!
I'm working on the application at http://demos.zatechcorp.com/codeigniter/
In its current incarnation running on my machine, I loaded the ZendFramework inside Codeigniter, and generated an index, like this:
// ... Some code that loads all the markets
foreach ($markets as $market)
{
$doc = new Zend_Search_Lucene_Document();
// Id for retrieval
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('id', $market->id));
// Store document URL to identify it in search result.
$doc->addField(Zend_Search_Lucene_Field::Text('url', $market->permalink));
// Index document content
$doc->addField(Zend_Search_Lucene_Field::UnStored('contents', $market->description));
// Title
$doc->addField(Zend_Search_Lucene_Field::Text('title', $market->title));
// Phone
$doc->addField(Zend_Search_Lucene_Field::Keyword('phone', $market->phone));
// Fax
$doc->addField(Zend_Search_Lucene_Field::Keyword('fax', $market->fax));
// Street
$doc->addField(Zend_Search_Lucene_Field::Keyword('street', $market->street));
// City
$doc->addField(Zend_Search_Lucene_Field::Keyword('city', $market->city));
// State
$doc->addField(Zend_Search_Lucene_Field::Keyword('state', $market->state));
// Zip
$doc->addField(Zend_Search_Lucene_Field::Keyword('zip', $market->zip));
// Type
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('type', 'market'));
// Store Document
$index->addDocument($doc);
}
In my search, I do this:
$hits = $index->find($q);
This works with simple words, but when I want to do a search like "Sheba Foods" (quotes included), it returns one result, but the wrong one, which doesn't even have the word "Sheba".
I moved away from MySQL full-text search because of its obvious problems, and can't make any headway with this.
I've been looking at the Zend_Search_Lucene_Search_QueryParser::parse() method. Does the answer lie in this method?
I figured it out. With Lucene, you can add a field with the name 'id', but retrieving id from a hit gives you something different -- I'll guess this is the id of the search term within the entire search results.
What I had to do in this case was use a different field name like this:
// Id for retrieval
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('item_id', $market->id));
I have used MySQL full-text search in the past, but it's really CPU intensive.
You could always rely on a SELECT * FROM table WHERE column = '%query%'