简体   繁体   English

从Solr获取数据到JTable

[英]Get data from Solr to JTable

I new in Solr. 我是索尔的新人。 I can add data to Solr from application, but I want to get data from Solr to my Java desktop application. 我可以从应用程序向Solr添加数据,但我想从Solr获取数据到我的Java桌面应用程序。

How can I get data from Solr ("http://localhost:8983/solr") ? 如何从Solr获取数据("http://localhost:8983/solr")

You probably want to use some solr client to requests and handle response data. 您可能希望使用一些solr客户端来请求和处理响应数据。

But you can do it in simple HTTP GET request if you want to like so: 但是如果您想这样,您可以在简单的HTTP GET请求中执行此操作:

// get all documents
http://localhost:8983/solr/select?q=*:*

If you're using multiple cores, then you probably need to use: 如果您使用多个核心,那么您可能需要使用:

// get all documents from core0
http://localhost:8983/solr/core0/select?q=*:*

You can read more about solr common query parameters here . 您可以在此处阅读有关solr 常见查询参数的更多信息。

Solrj is the easiest way to go. Solrj是最简单的方法。 It's the solr java client library. 它是solr java客户端库。 Add it as a dependency to your project, then write a pojo with all the fields that you want to get back from Solr. 将它作为依赖项添加到项目中,然后编写一个包含要从Solr返回的所有字段的pojo。 Annotate each field with the solrj @Field annotation , then send your query to Solr like this: 使用solrj @Field注释注释每个字段,然后将您的查询发送到Solr,如下所示:

SolrServer solrServer = new HttpSolrServer("htp://localhost:8080/solr/core0");
QueryResponse response = solrServer.query(new SolrQuery(query));
List<Pojo> pojos = response.getBeans(Pojo.class);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM