-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metod match('word word2') generate query type AND #70
Comments
I can't reproduce it, please provide a full script. E.g.: <?php
require_once __DIR__ . '/vendor/autoload.php';
use Manticoresearch\Client;
use Manticoresearch\Search;
$config = ['host'=>'127.0.0.1','port'=>9308];
$client = new \Manticoresearch\Client($config);
$index = $client->index('movies');
$params = [
'index' => 'movies',
['body' => ['silent'=>true ]]
];
$client->indices()->drop($params);
$index->create([
'title'=>['type'=>'text'],
'plot'=>['type'=>'text'],
'year'=>['type'=>'integer'],
'rating'=>['type'=>'float']
]);
$index->addDocuments([
['id'=>2,'title'=>'Interstellar','plot'=>'A team of explorers travel through a wormhole in space in an attempt to ensure humanity\'s survival.','year'=>2014,'rating'=>8.5],
['id'=>3,'title'=>'Inception','plot'=>'A thief who steals corporate secrets through the use of dream-sharing technology is given the inverse task of planting an idea into the mind of a C.E.O.','year'=>2010,'rating'=>8.8],
['id'=>4,'title'=>'1917 ','plot'=>' As a regiment assembles to wage war deep in enemy territory, two soldiers are assigned to race against time and deliver a message that will stop 1,600 men from walking straight into a deadly trap.','year'=>2018,'rating'=>8.4],
['id'=>5,'title'=>'Alien','plot'=>' After a space merchant vessel receives an unknown transmission as a distress call, one of the team\'s member is attacked by a mysterious life form and they soon realize that its life cycle has merely begun.','year'=>1979,'rating'=>8.4]
]);
$search = new Search($client);
$search->setIndex('movies');
$results = $search->profile()->match('spaceddd team')->get();
print_r($results);
foreach($results as $doc) {
echo 'Document:'.$doc->getId()."\n";
foreach($doc->getData() as $field=>$value)
{
echo $field.": ".$value."\n";
}
} ➜ ~ php test.php
Manticoresearch\ResultSet Object
(
[position:protected] => 0
[response:protected] => Manticoresearch\Response Object
(
[time:protected] => 0.00069093704223633
[string:protected] => {"took":0,"timed_out":false,"hits":{"total":2,"hits":[{"_id":"5","_score":1528,"_source":{"year":1979,"rating":8.400000,"title":"Alien","plot":" After a space merchant vessel receives an unknown transmission as a distress call, one of the team's member is attacked by a mysterious life form and they soon realize that its life cycle has merely begun."}},{"_id":"2","_score":1528,"_source":{"year":2014,"rating":8.500000,"title":"Interstellar","plot":"A team of explorers travel through a wormhole in space in an attempt to ensure humanity's survival."}}]},"profile":{"query":{"type":"OR","description":"OR( AND(KEYWORD(spaceddd, querypos=1)), AND(KEYWORD(team, querypos=2)))","children":[{"type":"AND","description":"AND(KEYWORD(spaceddd, querypos=1))","children":[{"type":"KEYWORD","word":"spaceddd","querypos":1}]},{"type":"AND","description":"AND(KEYWORD(team, querypos=2))","children":[{"type":"KEYWORD","word":"team","querypos":2}]}]}}}
[transportInfo:protected] => Array
(
[url] => http://127.0.0.1:9308/json/search
[headers] => Array
(
[0] => Content-Type: application/json
)
[body] => Array
(
[index] => movies
[profile] => 1
[query] => Array
(
[bool] => Array
(
[must] => Array
(
[0] => Array
(
[match] => Array
(
[*] => spaceddd team
)
)
)
)
)
)
)
[status:protected] => 200
[response:protected] => Array
(
[took] => 0
[timed_out] =>
[hits] => Array
(
[total] => 2
[hits] => Array
(
[0] => Array
(
[_id] => 5
[_score] => 1528
[_source] => Array
(
[year] => 1979
[rating] => 8.4
[title] => Alien
[plot] => After a space merchant vessel receives an unknown transmission as a distress call, one of the team's member is attacked by a mysterious life form and they soon realize that its life cycle has merely begun.
)
)
[1] => Array
(
[_id] => 2
[_score] => 1528
[_source] => Array
(
[year] => 2014
[rating] => 8.5
[title] => Interstellar
[plot] => A team of explorers travel through a wormhole in space in an attempt to ensure humanity's survival.
)
)
)
)
[profile] => Array
(
[query] => Array
(
[type] => OR
[description] => OR( AND(KEYWORD(spaceddd, querypos=1)), AND(KEYWORD(team, querypos=2)))
[children] => Array
(
[0] => Array
(
[type] => AND
[description] => AND(KEYWORD(spaceddd, querypos=1))
[children] => Array
(
[0] => Array
(
[type] => KEYWORD
[word] => spaceddd
[querypos] => 1
)
)
)
[1] => Array
(
[type] => AND
[description] => AND(KEYWORD(team, querypos=2))
[children] => Array
(
[0] => Array
(
[type] => KEYWORD
[word] => team
[querypos] => 2
)
)
)
)
)
)
)
[params:protected] => Array
(
)
)
[array:protected] => Array
(
[0] => Array
(
[_id] => 5
[_score] => 1528
[_source] => Array
(
[year] => 1979
[rating] => 8.4
[title] => Alien
[plot] => After a space merchant vessel receives an unknown transmission as a distress call, one of the team's member is attacked by a mysterious life form and they soon realize that its life cycle has merely begun.
)
)
[1] => Array
(
[_id] => 2
[_score] => 1528
[_source] => Array
(
[year] => 2014
[rating] => 8.5
[title] => Interstellar
[plot] => A team of explorers travel through a wormhole in space in an attempt to ensure humanity's survival.
)
)
)
[total:protected] => 2
[took:protected] => 0
[timed_out:protected] =>
[profile:protected] => Array
(
[query] => Array
(
[type] => OR
[description] => OR( AND(KEYWORD(spaceddd, querypos=1)), AND(KEYWORD(team, querypos=2)))
[children] => Array
(
[0] => Array
(
[type] => AND
[description] => AND(KEYWORD(spaceddd, querypos=1))
[children] => Array
(
[0] => Array
(
[type] => KEYWORD
[word] => spaceddd
[querypos] => 1
)
)
)
[1] => Array
(
[type] => AND
[description] => AND(KEYWORD(team, querypos=2))
[children] => Array
(
[0] => Array
(
[type] => KEYWORD
[word] => team
[querypos] => 2
)
)
)
)
)
)
[facets:protected] =>
)
Document:5
year: 1979
rating: 8.4
title: Alien
plot: After a space merchant vessel receives an unknown transmission as a distress call, one of the team's member is attacked by a mysterious life form and they soon realize that its life cycle has merely begun.
Document:2
year: 2014
rating: 8.5
title: Interstellar
plot: A team of explorers travel through a wormhole in space in an attempt to ensure humanity's survival. |
Sorry, its my bed constructor written by main README and 'match' added: $client = new \Manticoresearch\Client($config); its work but not good results:) looking at your code did that my correct code: $client = new \Manticoresearch\Client($config); So I ended up losing the evening looking at the main project readme.. |
doesn't make sense to me. If we have it somewhere please let me know or make a PR to fix it in the readme. But I can't find it.
So what's wrong? Can you provide:
|
ok i get you code: use Manticoresearch\Client; $config = ['host'=>'127.0.0.1','port'=>9308]; $params = [ $index->create([ $index->addDocuments([ //$search = new Search($client); print_r($results); foreach($results as $doc) { as you see results 0, but i hoped to see 2 result. |
Please point me to the place where it's said that you need to combine search() and match() in the same call. I can't find it.
You are trying to combine two different operators for some. You either use OR explicitly like: $results = $index->search('Interstellar|Inception', 'title')
->profile()
->get(); or you Again, if the documentation in some place you need to do so please let me know where exactly it's written. We'll need to change that. |
In documentation OR as default operator
I try profile()->match('word word2') and i see :
[query] => Array
(
[type] => AND
[description] => AND( AND( AND(KEYWORD(word, querypos=1)), AND(KEYWORD(word2, querypos=2))), OR( AND(KEYWORD(word, querypos=1)), AND(KEYWORD(word2, querypos=2))))....
if i set
->math(['query' => 'word word2', 'operator' => 'or'])
has no effect.
The text was updated successfully, but these errors were encountered: