-
Notifications
You must be signed in to change notification settings - Fork 963
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
No score on query #48
Comments
The sort is your problem. You'll notice that your PHP command and Sense commands are actually different, since you are requesting
Which give you similar NULL values in score. This is because you are asking Elasticsearch to only sort by the In PHP: $json='{
"filter":{
"term":{
"url":"%s"
}
},
"query":{
"match":{
"linktext":"%s"
}
}
}';
$qStr = sprintf($json,$url,$anchortext);
$params['index'] =get_domain_index($requesturl,"inverted");
$params['type'] ="inverted";
$params['fields'] ="_score,url,referer,linktext";
$params['body'] =$qStr;
$params['sort']="url_date:desc,_score:desc"; // Notice the addition to _score here
$params['size']=100;
try{
$rc = $GLOBALS['e']->search($params);
}catch (Exception $error){
echo "Not found\n";
//echo $error." Error Getting record\n";
} And in Sense:
That should fix your problem :) Now, with that said, you should probably be specifying the sort value in the query body rather than the URL parameters, since it allows more configuration: $json='{
"filter":{
"term":{
"url":"%s"
}
},
"query":{
"match":{
"linktext":"%s"
}
},
"sort": [
{
"url_date": {
"order": "desc"
}
},
{
"_score": {
"order": "desc"
}
}
]
}';
$qStr = sprintf($json,$url,$anchortext);
$params['index'] =get_domain_index($requesturl,"inverted");
$params['type'] ="inverted";
$params['fields'] ="_score,url,referer,linktext";
$params['body'] =$qStr;
$params['size']=100;
try{
$rc = $GLOBALS['e']->search($params);
}catch (Exception $error){
echo "Not found\n";
//echo $error." Error Getting record\n";
} |
WOW!!! What a great answer.. Makes perfect sense. Thank you very very much |
No problem, glad to help :) Closing this ticket, feel free to reopen or make a new one if you have any other issues. |
I executing a query this is the query
$json='{
"filter": {"term": {
"url": "%s"
}},
"query": {"match": {
"linktext": "%s"
}}
}';
$qStr = sprintf($json,$url,$anchortext);
each record comes back with a NULL score
[98]=>
array(6) {
["_index"]=>
string(10) "inverted-p"
["_type"]=>
string(8) "inverted"
["_id"]=>
string(32) "255718a4b0d3a938360d4d2f92070e40"
["_score"]=>
NULL
["fields"]=>
array(3) {
["linktext"]=>
array(1) {
[0]=>
string(124) "
However when i exectue the same request with Sense I get the score
POST /inver*/_search
{
"filter": {"term": {
"url": "porscheofranchomirage.com"
}},
"query": {"match": {
"linktext": "porsche dealer"
}}
}
"_index": "inverted-p",
"_type": "inverted",
"_id": "be30dd48eea377b389623318186e3141",
"_score": 2.1395235,
"_source": {
"tld": "porscheofranchomirage.com",
"url": "porscheofranchomirage.com",
"referer": "indigoautogroupsocal.com",
"linktext": "Porsche",
"url_date": "2014-03-03"
}
},
{
"_index": "inverted-p",
"_type": "inverted",
"_id": "7582fb1eb94eec4a8fd3f7e0662b3e9d",
"_score": 1.0697618,
"_source": {
"tld": "porscheofranchomirage.com",
"url": "porscheofranchomirage.com",
"referer": "riversidepca.org",
"linktext": "Porsche of Rancho Mirage",
"url_date": "2014-03-03"
Can you please tell how to get the score in my code.
Thanks
The text was updated successfully, but these errors were encountered: