在Solr上搜索名称 [英] Name Search on Solr

查看:88
本文介绍了在Solr上搜索名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉,如果我要发布重复的问题,请这样指出原始问题.

Apologies if I am posting a duplicated question, if so please point me to original question.

我是solr的新手,正在尝试使用solr进行有序的单词名称搜索.我希望得到solr的以下答复

I am a solr novice and trying to achieve ordered word name search using solr.I am expecting following response from 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 Data Solr使用MethodName生成查询. 请帮助我如何构成我的模式以对这些数据建立索引以及应使用哪些过滤器?

I am generating queries using MethodName using spring data solr. Please help me how I should form my schema to index this data and what filters I should use ?

还指导我如何从适当的结果中使用spring数据Solr使用methodName形成查询.

Also guide me how to form the queries using methodName using spring data solr from appropriate result.

推荐答案

您的schema.xml可能是随solr一起提供的一个,因为其中已经存在一个名为name的字段(已标记和索引),如下所示:

Your schema.xml may be the one delivered with solr because there is already a field named name (tokenized and indexed) in there as follows:

<field name="name" type="text_general" indexed="true" stored="true"/>

所以您要做的就是在该索引上创建一个文档:

so all you need to do is to create a document on that index:

curl localhost:8983/solr/collection1/update/json?commit=true -H 'Content-type:application/json' -d '
[
  {
    "id" : "1",
    "name" : "Thomas Edison"
  }
]'

您可能有一个Java类,或多或少代表您的文档结构,如下所示:

You probably have a java class representing your document structure more or less as follows:

@SolrDocument(solrCoreName = "collection1")
public class Person {

    @Id
    private Long id;
    @Indexed
    private String name;

    // setters and getters

}

和如下的存储库:

public interface PersonDao extends SolrCrudRepository<Person, Long> {

    // derivable method names here

}

为了进行基于名称的搜索,可以声明以下方法:

in order to have a search based on name you can declare the following method:

List<Person> findByName(String name);

当该字段被标记后,它将在该字段的标记内搜索提供的参数.这将带来您期望的结果.

As the field is tokenized, it will search for the provided parameter within a token from that field. This will lead to the results you are expecting.

这篇关于在Solr上搜索名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆