CakePHP, MongoDB: How to search field from Collection - mongodb

I want to implement functionality that will search the record from mongoDB. I am using ichikaway plugin.
I tried the cakephp like clause mentioned here, but did not worked for me :(.
please let me if there is any approach to achieve this.
Thanks in advance

After doing search around I have found solution
$conditions = array('field_name' => new MongoRegex('/'.$value.'/i'));
where i trans to case-insensitive.

Related

TYPO3 queryBuilder: How to work with BINARY in where() clause?

I just have a short question.
There's no description in the following API overview of TYPO3 how to use a "BINARY" in where() clause: https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Database/QueryBuilder/Index.html#expr
What I want to achieve? this one:
WEHRE BINARY `buyer_code` = "f#F67d";
Actually I can only do the following:
->where(
$queryBuilder->expr()->eq('buyer_code', 'f#F67d')
);
But in this case I don't get a satisfying result for myself because I need case-sensitive here :-)
An another buyer_code exists "f#F67D" (the last char is uppercase) but I do need to look for the other one.
Thanks for helping.
Since TYPO3 is using Doctrine API here, you could try to do
->where('BINARY `buyer_code` = ' . $queryBuilder->createNamedParameter('f#F67d'))
Please keep in mind, that this query now only works for database backends, supporting the BINARY keyword!
Please have a look at Doctrine2 case-sensitive query The thread is a bit older, but seems to cover background and solution for your problem.

How do you search an array of documents in mongo dart?

How do I search an array of documents in mongodb using the dart programming language?
Im using https://pub.dartlang.org/packages/mongo_dart for the driver
The example db collection looks like this
"name": [
{"full":"Tyler Thompson",
"first":"Tyler",
"last":"Thompson"
}
]
Using the following query will help achieve your goal for the one name
String search = "Tyler";
{"name.full": {'\$regex': '${search}'}
Hope that helps! Couldn't find an example, so I thought I'd give one!:)
You can try to look at https://github.com/vadimtsushko/mongo_dart/blob/master/example/queries.dart
It is plausible that for your sample something like this would work:
coll.find(where.eq('name.full','Tyler'))
or maybe
coll.find(where.match('name.full','^Tyl[eo]r'))

Reverse search at mongodb

I have tried to search around for clues but didn't find any.
Please let me ask a question about reverse search for mongodb.
I have a collection that contain a phone prefix, let say bellow.
{"prefix":"1234"}
and i am trying to make it hit with value like 12341111 or 12342222 ...
in MySQL i can do it with below SQL.
SELECT * from phoneprefix where ‘12341111’ like concat(prefix,’%’)
Is there anyway to make it possible at mongodb ?
Thanks for reading my post and please have a nice day !
The only way I can see to do this is to use the performance-challenged $where operator:
db.phoneprefix.find({$where: function() {
return (new RegExp('^' + this.prefix)).test('12341111');
}});
You could use $regex in MongoDB.

Facing issue when search using Zend_Lucene

I am using zend_lucene for search functionality.I 've the following code,
$doc->addField(Zend_Search_Lucene_Field::Text('categoryName', $result->name));
Here name in "$result->name" is varchar type in Database. Also have some following values like dinesh,kumar123,3333. For testing purpose i have stored number in name field. when i search dinesh , Search comes with exact result but when i use number search, That is 3333 Search has no result. What i done wrong on the code Zend_Search_Lucene_Field::Text.
Is there any way for search number/char/alphanumeric (kumar123) ?
Thanks in Advance
Finally i found by declaring "Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());" and use Zend_Search_Lucene_Field::Keyword instead of Zend_Search_Lucene_Field::Text

How to get whole index in ZEND Lucene?

Hi I am looking for a way to get the whole index if my query is nothing.
My lucene is a picture of my database without some unwanted content, like expired annonces...
So I would like to use only lucene to get annonces, and for that I need a way to get the whole index.
Any ideas?
thanks!
This is not the answer but something wich works for me:
Using an indexKey like is_indexed, always true.
I am adding "is_indexed:1" to my query and it works...
If you have something else, let me know!
I tend to use a field which is named after the index such as:
$oDoc->addField(
Zend_Search_Lucene_Field::keyword(
'index',
'availability'
)
);
Then the term query will return all fields. It's not pretty but it works fine.