SphinxSearch完全匹配排名(SphinxSearch exact match ranking)
我注意到使用Sphinx 2.2.8的排序顺序中有一个奇怪的行为(与v2.3.1-beta相同的结果)。
我希望精确匹配出现在第一个位置(我为此设置了index_exact_words和expan_keywords)。
这对我下面的第一个例子有两行有效。 但是如果我添加更多行,权重会更改,我的完全匹配结果(id = 1)会比其他近似值更低!
例如,索引这两个单词(一些带有形态学libstemmer_fr的法语单词):
source nptest { type = pgsql sql_host = localhost sql_user = myuser sql_pass = mypassword sql_db = mydb sql_port = 5432 sql_query = \ SELECT 1, 'chien' AS val \ UNION \ SELECT 2, 'chienne' sql_field_string = val } index nptest { type = plain mlock = 1 source = nptest path = /var/lib/sphinx/data/nptest morphology = libstemmer_fr index_exact_words = 1 expand_keywords = 1 }
索引后(indexer --rotate nptest):
mysql> SELECT id, val, weight() FROM nptest WHERE match('chien'); +------+---------+----------+ | id | val | weight() | +------+---------+----------+ | 1 | chien | 1500 | | 2 | chienne | 1428 | +------+---------+----------+ 2 rows in set (0.00 sec)
“chien”这个词的排名高于“chienne”=>这就是我的预期。
现在我向db添加更多行:
source nptest { type = pgsql sql_host = localhost sql_user = myuser sql_pass = mypassword sql_db = mydb sql_port = 5432 sql_query = \ SELECT 1, 'chien' AS val \ UNION \ SELECT 2, 'chienne' \ UNION \ SELECT 3, 'un beau chien' \ UNION \ SELECT 4, 'chien-loup' sql_field_string = val } mysql> SELECT id, val, weight() FROM nptest WHERE match('chien'); +------+---------------+----------+ | id | val | weight() | +------+---------------+----------+ | 2 | chienne | 1402 | | 1 | chien | 1373 | | 3 | un beau chien | 1373 | | 4 | chien-loup | 1373 | +------+---------------+----------+ 4 rows in set (0.00 sec)
重新索引后,最高级别现在是“chienne”!
这是正常的行为(如果是这样的原因?)或者它是一个错误? 如果它不是错误,我怎样才能确保完全匹配将获得最高排名?
I noticed a strange behavior in the sort order using Sphinx 2.2.8 (same result with v2.3.1-beta).
I expect exact matching to appear on first position (I set index_exact_words and expan_keywords for that).
That works well on my first example below with two rows. But if I add more rows, weights change and my exact match result (id=1) gets a lower rank than other approximate one!
For example, indexing these 2 words (some french words with morphology libstemmer_fr):
source nptest { type = pgsql sql_host = localhost sql_user = myuser sql_pass = mypassword sql_db = mydb sql_port = 5432 sql_query = \ SELECT 1, 'chien' AS val \ UNION \ SELECT 2, 'chienne' sql_field_string = val } index nptest { type = plain mlock = 1 source = nptest path = /var/lib/sphinx/data/nptest morphology = libstemmer_fr index_exact_words = 1 expand_keywords = 1 }
After indexing (indexer --rotate nptest):
mysql> SELECT id, val, weight() FROM nptest WHERE match('chien'); +------+---------+----------+ | id | val | weight() | +------+---------+----------+ | 1 | chien | 1500 | | 2 | chienne | 1428 | +------+---------+----------+ 2 rows in set (0.00 sec)
The word "chien" has a higher rank than "chienne" => that's what I expected.
Now I add more rows to my db:
source nptest { type = pgsql sql_host = localhost sql_user = myuser sql_pass = mypassword sql_db = mydb sql_port = 5432 sql_query = \ SELECT 1, 'chien' AS val \ UNION \ SELECT 2, 'chienne' \ UNION \ SELECT 3, 'un beau chien' \ UNION \ SELECT 4, 'chien-loup' sql_field_string = val } mysql> SELECT id, val, weight() FROM nptest WHERE match('chien'); +------+---------------+----------+ | id | val | weight() | +------+---------------+----------+ | 2 | chienne | 1402 | | 1 | chien | 1373 | | 3 | un beau chien | 1373 | | 4 | chien-loup | 1373 | +------+---------------+----------+ 4 rows in set (0.00 sec)
After reindexing the highest rank is now on "chienne"!
Is this a normal behaviour (if so why?) or is it a bug? If it is not a bug, how can I ensure that exact matching will get the highest rank ?
原文:https://stackoverflow.com/questions/29073517
最满意答案
换行:
arrayToFill =[arrayToFill insertObject:dictionary atIndex:i];
至
[arrayToFill insertObject:dictionary atIndex:i];
您无需再次分配它,只需调用insert方法即可
Change the line:
arrayToFill =[arrayToFill insertObject:dictionary atIndex:i];
to
[arrayToFill insertObject:dictionary atIndex:i];
You don't need to assign it again, just call the insert method
相关问答
更多-
换行: arrayToFill =[arrayToFill insertObject:dictionary atIndex:i]; 至 [arrayToFill insertObject:dictionary atIndex:i]; 您无需再次分配它,只需调用insert方法即可 Change the line: arrayToFill =[arrayToFill insertObject:dictionary atIndex:i]; to [arrayToFill insertObject:dict ...
-
听起来该属性设置为copy ,这意味着合成访问器生成数组的不可变副本 It sounds like the property is set to copy, which means the synthesized accessor makes an immutable copy of the array
-
当调用insertObject:in
AtIndex:时,是否应通知观察者?(Should observers be notified when insertObject:in [2023-12-11]AtIndex: is called?) 这是因为你没有实现insert和remove方法。 “你说的话。 “我也是这样做的!” 不,不完全。 差不多,但是你说错了:它是From TheArrayAtIndex: . 应用该修复后,所有六个更改都会导致观察者通知。 It's because you didn't implement both the insert and the remove method. “What!”, you say. “I did too!” No, not quite. Almost, but you got a wor ... -
UITextField *valueField = [[UITextField alloc] initWithFrame:CGRectMake(165,6, 135, 30)]; valueField.borderStyle = UITextBorderStyleRoundedRect; valueField.text = @""; [cell addSubview:valueField]; [array1 addObject:valueField.text]; [valueField release]; ...
-
如果你想以与C固定大小数组相同的方式使用NSArray ,我建议你为数组大小填充NSArray实例尽可能多的[NSNull null] ,例如在这种情况下为10个项目。 NSMutableArray *myArray = [NSMutableArray arrayWithCapacity:10]; for(int i = 0; i < 10; i++) { [myArray addObject:[NSNull null]]; } 当你想插入对象时,请改用replaceObjectAtIndex:w ...
-
正如其他人所说的那样,您将nil对象插入代码中的某个数组中。 调试器不是很好地报告发生错误的源代码行。 它可能表明它在main.m中,但这显然是错误的。 尝试在所有Objective-C异常上设置全局断点。 这通常会导致Xcode向您显示导致崩溃的实际行。 (不需要在main.m中使用try / catch,它甚至可能会混淆。) 编辑: 好的,我想我看到你在答案中改变了什么。 您添加了第二个堆栈跟踪。 您的崩溃日志是否仍然声称main.m中发生了错误? 从第二个崩溃日志开始,打开初始视图控制器的视图控制器场 ...
-
您需要初始化positionIcons ,将代码更改为: NSMutableArray *positionIcons = [[NSMutableArray alloc] init]; [positionIcons insertObject:annotation atIndex:0]; positionIcons = [NSArray arrayWithObjects:annotation, nil]; You need to initialize positionIcons, change the cod ...
-
[__NSArrayM insertObject:atIndex:]:对象不能为零([__NSArrayM insertObject:atIndex:]: object cannot be nil)[2022-08-02]
最后错误已经解决。 我开始了一个新的空项目,从一开始就完成了所有的工作。 因为我也是旧版的复制粘贴,所以每一步都会逐步运行。 应用程序运行没有问题。 我完成了它,现在它运行了。 我可以理解为什么以及这个错误是什么,但是在一个新项目中(与旧项目具有相同的代码)问题不存在! 无论如何,谢谢你的帮助。 finally the error has been resolved. I started a new empty project and did all the work from the beginning. ... -
问题在这里,我想是的, for (NSDictionary *diction in arraydata) { NSString *message =[diction objectForKey:@"message"]; [array addObject:message]; //here some value is nil means you are trying to add a nil object to array that's why app getting crashed. ...
-
该错误消息告诉您self.revealViewController.panGestureRecognizer为nil,这可能是由self.revealViewController为nil引起的。 That error message is telling you that self.revealViewController.panGestureRecognizer is nil, which may be caused by self.revealViewController being nil.