如果我发布重复的问题,请道歉,如果是,请指出原始问题。
我是solr新手并尝试使用solr实现有序的单词名称搜索。我期待以下来自solr的回复
Name Search Term Result
Thomas Alva Edison Thomas Match
Thomas Alva Edison Alva Match
Thomas Alva Edison Edison Match
Thomas Alva Edison Thomas Edison Match
Thomas Alva Edison Thomas Alva Match
Thomas Alva Edison Alva Edison Match
Thomas Alva Edison Thomas Alva Edison Match
Thomas Alva Edison homas No Match
Thomas Alva Edison Edison Thomas No Match
Thomas Alva Edison homas edison No Match
Thomas Alva Edison homas dison No Match
我使用Spring数据solr使用MethodName生成查询。 请帮助我如何构建我的架构来索引这些数据以及我应该使用哪些过滤器?
还指导我如何使用带有适当结果的spring数据solr的methodName来形成查询。
答案 0 :(得分:1)
您的schema.xml
可能是与solr
一起发送的name
因为已存在名为<field name="name" type="text_general" indexed="true" stored="true"/>
(已标记化并已编入索引)的字段,如下所示:
curl localhost:8983/solr/collection1/update/json?commit=true -H 'Content-type:application/json' -d '
[
{
"id" : "1",
"name" : "Thomas Edison"
}
]'
所以您需要做的就是在该索引上创建一个文档:
@SolrDocument(solrCoreName = "collection1")
public class Person {
@Id
private Long id;
@Indexed
private String name;
// setters and getters
}
您可能有一个或多或少代表您的文档结构的java类,如下所示:
public interface PersonDao extends SolrCrudRepository<Person, Long> {
// derivable method names here
}
和存储库如下:
List<Person> findByName(String name);
要根据名称进行搜索,您可以声明以下方法:
$('#graphMenu')
.mouseenter(function(e) {
$(this).data('hovered', true);
})
.mouseleave(function(e) {
$(this).data('hovered', false);
});
$('body').on('contextmenu', options.contextMenu.graphName, function (event) {
showContextMenu(event);
});
$(document).bind('click', function (event) {
if (!$('#graphMenu').data('hovered'))
$('#graphMenu').hide();
});
当字段被标记化时,它将从该字段中搜索令牌中提供的参数。这将导致您期望的结果。
答案 1 :(得分:0)
对于那个相当具体的需求,我不会想到过滤器/标记器。
你可以尝试的是SurroundQueryParser(我自己没试过)
如果那对你不起作用,那可能会让你感到伤心,如果我在哪里,我会考虑某种定制: