<?php

 $options = array
(
'hostname' => 'localhost',
'port' => '8080',
'path' => 'solr/help_category',
'wt' => 'json'
);
$client = new SolrClient($options);
try {
$client->ping();
} Catch (Exception $e) {
exit('未连接');
} $query = new SolrQuery();
$query->setQuery('title:账户'); $query->setStart(0);
$query->setRows(20); $query->addField('title')->addField('id');
$query->addHighlightField('title');
$query->setHighlight(true);
$query->setHighlightSimplePre("<span style='color:blue'>");
$query->setHighlightSimplePost('</span>'); $query_response = $client->query($query);
$response = $query_response->getResponse();
var_dump($query_response->getRequestUrl());
var_dump($query_response->getRawRequest());
var_dump($response['highlighting']); //可以通过foreach找出高亮部分
if ($response['response']['numFound'] > 0) {
foreach ($response['response']['docs'] as $doc) {
echo $doc['title'];
echo '<br><br>';
}
}
?>

PHP搜索Solr文档(含高亮)的更多相关文章

  1. atitit.vod search doc.doc 点播系统搜索功能设计文档

    atitit.vod search doc.doc 点播系统搜索功能设计文档 按键的enter事件1 Left rig事件1 Up down事件2 key_events.key_search = fu ...

  2. solr 文档一

    [在此处输入文章标题] 参考博客: http://blog.csdn.net/matthewei6/article/details/50620600 基础环境搭建 solr版本5.5.5: 一.sol ...

  3. Solr记录-solr文档xml

    Solr添加文档(XML) 在上一章中,我们学习解释了如何向Solr中添加JSON和.CSV文件格式的数据.在本章中,将演示如何使用XML文档格式在Apache Solr索引中添加数据. 示例数据 假 ...

  4. solr 文档二

    SOLR 5.5.5文档 参考博文: http://blog.csdn.net/matthewei6/article/details/50620600 作者:毛平 时间:2018年1月15日 17:3 ...

  5. PHP删除Solr文档

    <?php $options = array ( 'hostname' => 'localhost', 'port' => '8080', 'path'=>'solr/help ...

  6. Solr开发参考文档(转)

    Solr开发文档 Solr 是一种可供企业使用的.基于 Lucene 的搜索服务器,它支持层面搜索.命中醒目显示和多种输出格式.在这篇文章中,将介绍 Solr 并展示如何轻松地将其表现优异的全文本搜索 ...

  7. Solr 18 - 通过SolrJ局部更新Solr中的文档 (原子操作、非覆盖操作)

    目录 1 需求分析 2 需求实现 2.1 pom.xml依赖 2.2 Java代码示例 3 补充说明 3.1 关于文档中_version_的取值说明 3.2 store=true/false的区别 1 ...

  8. 海量Office文档搜索

    知识管理系统Data Solution研发日记之十 海量Office文档搜索   经过前面两篇文章的介绍,<分享制作精良的知识管理系统 博客备份程序 Site Rebuild>和<分 ...

  9. SearchRequest用于与搜索文档、聚合、定制查询有关的任何操作

    SearchRequest用于与搜索文档.聚合.定制查询有关的任何操作,还提供了在查询结果的基于上,对于匹配的关键词进行突出显示的方法. 1,首先创建搜索请求对象:SearchRequest sear ...

随机推荐

  1. Linux Kernel 远程拒绝服务漏洞

    漏洞名称: Linux Kernel 远程拒绝服务漏洞 CNNVD编号: CNNVD-201307-309 发布时间: 2013-07-18 更新时间: 2013-07-18 危害等级:    漏洞类 ...

  2. BZOJ1589: [Usaco2008 Dec]Trick or Treat on the Farm 采集糖果

    1589: [Usaco2008 Dec]Trick or Treat on the Farm 采集糖果 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 4 ...

  3. 【转】google chrome如何设置主页

    原文网址:http://jingyan.baidu.com/article/8275fc86bf916c46a13cf666.html google chrome是一款拥有众多优秀插件的浏览器,是我们 ...

  4. [JAVA关键字] static & final

    JAVA十分常见的关键字static & final 总的来说final表示常量,即不可更改的:而static表示静态,即全局的 1. final 类:不能被继承 2. final 方法:能被 ...

  5. [转]stringstream的用法

    使用stringstream对象简化类型转换C++标准库中的<sstream>提供了比ANSI C的<stdio.h>更高级的一些功能,即单纯性.类型安全和可扩展性.在本文中, ...

  6. cookie操作大全

    JavaScript中的另一个机制:cookie,则可以达到真正全局变量的要求. cookie是浏览器 提供的一种机制,它将document 对象的cookie属性提供给JavaScript.可以由J ...

  7. Directx 3D编程实例:绘制3DMesh

    最近朋友建议我写一些关于微软云技术的博客留给学校下一届的学生们看,怕下一届的MSTC断档.于是我也觉的有这个必要.写了几篇博客之后,我觉得也有必要把这一年的学习内容放在博客做个纪念,就这样写了本篇博客 ...

  8. HDOJ 5073 Galaxy 数学 贪心

    贪心: 保存连续的n-k个数,求最小的一段方差... .预处理O1算期望. .. Galaxy Time Limit: 2000/1000 MS (Java/Others)    Memory Lim ...

  9. [PWA] 6. Hijacking response

    For example, if the url is not match to any API endpoint, we want to return 404 error message. So fi ...

  10. [Angular 2] Exposing component properties to the template

    Showing you how you can expose properties on your Controller to access them using #refs inside of yo ...