使用Solrj(查询和索引编制)

时间:2018-11-23 14:39:40

标签: java curl solr solrj solrcloud

e使用Solr从事自然语言处理项目。

就Solr而言,我是一个完全的业余爱好者,所以请记住这一点。我使用cmd启动了一个solr服务器:

SELECT

`wp_posts`.`ID` AS `EventID`,
`wp_posts`.`post_parent` AS `SeriesID`,
`wp_posts`.`post_title` AS `EventTitle`,
`wp_posts`.`post_content` AS `EventDescription`,
`wp_posts`.`post_excerpt` AS `EventSummary`,
`wp_posts`.`post_name` AS `EventSlug`,
min(`wp_postmeta`.`meta_value`) AS `EventStartDate`,
max(`tribe_event_end_date`.`meta_value`) AS `EventEndDate`,
`wp_posts`.`guid` AS `GUID`

FROM ((`wp_posts` 
JOIN `wp_postmeta` ON
(
  (`wp_posts`.`ID` = `wp_postmeta`.`post_id`)
)) 

LEFT JOIN `wp_postmeta` `tribe_event_end_date` ON
(
  (
    (`wp_posts`.`ID` = `tribe_event_end_date`.`post_id`) AND
    (`tribe_event_end_date`.`meta_key` = '_EventEndDate')
  )
))


WHERE
(
  (`wp_postmeta`.`meta_key` = '_EventStartDate') AND
  (`wp_posts`.`post_type` = 'tribe_events') AND
  (`wp_posts`.`post_status` = 'publish') AND
  (`tribe_event_end_date`.`meta_value` >= CURDATE())  
) 

GROUP BY 
`wp_posts`.`ID` 
ORDER BY 
`EventStartDate`,
`wp_posts`.`post_date`; 

然后我尝试使用SolrJ进行查询

 Solr.cmd Start -e techproducts

运行时,我得到了:

  

线程“主”中的异常
  org.apache.solr.client.solrj.impl.HttpSolrClient $ RemoteSolrException:服务器在http://localhost:8983/solr/#处发生错误:预期的MIME类型为application / octet-stream,但获得了text / html。   

请注意,当我在两个群集服务器上尝试该查询时,此查询有效(如“ http://lucene.apache.org/solr/guide/7_5/solr-tutorial.html”中所示

有人可以解释一下两者之间的区别吗

public class SolrJ {
    public static void main(String[] args) throws SolrServerException, IOException {
    SolrClient client = new Builder("http://localhost:8983/solr/#").build();
        QueryResponse response = client.query(new SolrQuery("*:*"));
    SolrDocumentList results = response.getResults();
    for (int i = 0; i < results.size(); ++i) {
        System.out.println(results.get(i));
    }
}
}

Solr.cmd -e cloud

为什么只有云有集合?

此外,我正在努力使用API​​覆盖solr.cmd -e techproducts 文件,有人可以解释一下创建覆盖SolrConfig.xml的API所需的步骤。我尝试使用curl命令从cmd这样做,但是我认为这是错误的方法。可通过http://localhost:8983/solr/techproducts/config访问config API 但是我怎么用呢?

我为不连贯表示歉意,这是我第一次在Stack Overflow上发布任何内容。

谢谢!

0 个答案:

没有答案