Questions A

7 views
Skip to first unread message

BlackMage

unread,
Jan 27, 2012, 10:55:06 AM1/27/12
to MongoLantern
Hey Everyone,

So I have MongoLantern to be potentially used in 3 different sites to
implement in but I am having a few problems.

1. Searching Multiple Terms

In the chunks for an item, I have {'cat','bat', 'boat'}

When searching, if I pass in:

$search->setQuery('cat');

It works. But if I do :

$search->setQuery('cat dog');

It fails. So how can I search for possible multiple terms? Looking the
the code I noticed its tokenizing data.

2. Dictionary

Reviewing the code, I found a way of disabling the dictionary and
decided to add a constant as a way of turning the dictionary
synchronization on or not.

Also for the dictionary, batchInserts would speed up the process. The
figure .025 given per term is variable depending on a multitude of
factors.

Sougata Pal.

unread,
Jan 27, 2012, 11:01:29 AM1/27/12
to mongol...@googlegroups.com

Yes.

Try change matchmode to "ANY" and see whether it returns results for you.

Thanks
Sougata Pal

- Sent via Google Android

Sougata Pal.

unread,
Jan 27, 2012, 11:11:30 AM1/27/12
to mongol...@googlegroups.com
Code Example FOR MULTIPLE TERMS match

$search = new MongoLanternQuery();
$search->indexName = 'youindexname';
$search->Connect();

$keyword = 'cat dog';

$search->setQuery($keyword);

$search->setMatchMode('ANY');

$search->setSortMode('RANK');

$search->setIntelligentQueryMode(true);

$resultList = $search->Execute($limit);
--
Thanks
Sougata Pal.
Chief Architect, Techunits
http://in.linkedin.com/in/skallpaul
Contact: +91 9051042886

BlackMage

unread,
Jan 27, 2012, 11:16:41 AM1/27/12
to MongoLantern
Ok, here is what is weird.

$search->setQuery('cat dog');

works

$search->setQuery('Get the cat of the balcony');

works

$search->setQuery('dog cat');

doesn't work

On Jan 27, 11:11 am, "Sougata Pal." <skall.p...@gmail.com> wrote:
> *Code Example FOR MULTIPLE TERMS match*
>
> $search = new MongoLanternQuery();
> $search->indexName = 'youindexname';
> $search->Connect();
>
> $keyword = 'cat dog';
>
> $search->setQuery($keyword);
> *
> *$search->setMatchMode('ANY');*
>
> *$search->setSortMode('RANK');*
>
> *$search->setIntelligentQueryMode(true);*
>
> *$resultList = $search->Execute($limit);

Sougata Pal.

unread,
Jan 27, 2012, 11:18:11 AM1/27/12
to mongol...@googlegroups.com
can you place following codeblock before $search->Execute() and get me the output.

$search->debug = true;

BlackMage

unread,
Jan 27, 2012, 11:20:02 AM1/27/12
to MongoLantern
MongoLanternQuery Object
(
[debug] => 1
[host] => localhost
[port] => 27017
[indexName] => Images
[tokenSymbols] => -,&:#
[defaultCharacterEncoding:protected] => utf-8
[collectionPrefix:protected] => lanternRawIndex
[collection:protected] => lanternRawIndex_Images
[finalqueryObj:protected] => Array
(
[$or] => Array
(
[0] => Array
(
[document.tokenChunks] => Array
(
[$all] => Array
(
[0] => MongoRegex Object
(
[regex] =>
1327699404
[flags] =>
)

)

)

)

[1] => Array
(
[document.tokenChunks] => Array
(
[$in] => Array
(
[0] => MongoRegex Object
(
[regex] =>
1327699404
[flags] =>
)

)

)

)

)

)

[lanternVersion:protected] => 0.5
[benchmarkStats:protected] => MongoLanternBenchmark Object
(
)

[queryStats:protected] =>
[resultsCount:protected] => 0
[indexKeys:protected] => Array
(
[0] => documentID
[1] => document.tokenChunks
[2] => created
)

[availableIndexes:protected] => Array
(
[0] => _id
[1] => created
[2] => document.tokenChunks
[3] => documentID
[4] => document.tags
)

[database:MongoLanternBase:private] => MongoLantern
[requiredPHPExtensions:MongoLanternBase:private] => Array
(
[0] => mongo
[1] => mbstring
)

[matchMode] => ANY
[sortMode] => RANK
[fieldqueryObj] =>
[intelligentQueryMode] => 1
[_skip] => 0
[_limit] => 10
[MongoDBH] => MongoDB Object
(
[w] => 1
[wtimeout] => 10000
)

[queryObj] => Array
(
[0] => 1327699404
[keyword] => cat abc
)

[queryExplain] => Array
(
[cursor] => BasicCursor
[nscanned] => 1
[nscannedObjects] => 1
[n] => 0
[millis] => 33
[nYields] => 0
[nChunkSkips] => 0
[isMultiKey] =>
[indexOnly] =>
[indexBounds] => Array
(
)

[allPlans] => Array
(
[0] => Array
(
[cursor] => BasicCursor
[indexBounds] => Array
(
)

)

)

[oldPlan] => Array
(
[cursor] => BasicCursor
[indexBounds] => Array
(
)

)

)

)
!!! end debug !!!

Sougata Pal.

unread,
Jan 27, 2012, 11:23:14 AM1/27/12
to mongol...@googlegroups.com
Thanks a lot. Let me reproduce the issue and get back to you with the solution.

BlackMage

unread,
Jan 27, 2012, 11:25:41 AM1/27/12
to MongoLantern
It seems strange the regex is outputting numbers if there are two
cases.

BlackMage

unread,
Jan 27, 2012, 11:25:53 AM1/27/12
to MongoLantern
Ok, thanks

BlackMage

unread,
Jan 27, 2012, 11:40:05 AM1/27/12
to MongoLantern
Right here is the cause of the problem:

if(false !== ($contentDate = strtotime($content))) { // check for
valid date+time

return (int) $contentDate;

Sougata Pal.

unread,
Jan 27, 2012, 11:41:16 AM1/27/12
to mongol...@googlegroups.com
Yes.  I have already fixed the issue and launching the latest version as MongoLantern-0.6-rc0.1.  You can have it from sourceforge in few minutes.

BlackMage

unread,
Jan 27, 2012, 12:22:38 PM1/27/12
to MongoLantern
Ok, it works now. You took out the line all together. How come is was
there to begin with?

Sougata Pal.

unread,
Jan 27, 2012, 12:24:43 PM1/27/12
to mongol...@googlegroups.com
As there was error on that line which could be logically fatal so I removed. We will plan the conversion little more and put it there.


Thanks for your contribution. Please let me know if you require something else.

BlackMage

unread,
Jan 27, 2012, 12:29:37 PM1/27/12
to MongoLantern
No thanks. The only thing tha I would comment about is the dictionary.
It's a large file that might be better suited if imported to mongo
through the command line. PHP way is really. I left mine run for an
hour and it only got to 10 megs.

Sougata Pal.

unread,
Jan 27, 2012, 12:34:07 PM1/27/12
to mongol...@googlegroups.com
Yes. True.  We will still planning the dictionary feature more to have best performance.
Reply all
Reply to author
Forward
0 new messages