好久没有写关于umbraco的博客了,这段时间在研究solis search,感觉它太强大,好东西是需要分享的,所以写一篇简单的使用博客分享给个人umbraco爱好者。
简介
在了解solis search之前,我们需要简单的了解apache solr, Apache Solr 是一个开源的搜索服务器。Solr 使用 Java 语言开发,主要基于 HTTP 和 Apache Lucene 实现。Lucene是一套用于全文检索和搜寻的开源程式库,由Apache软件基金会支持和提供。Lucene提供了一个简单却强大的应用程式接口,能够做全文索引和搜寻。更详细的介绍请充分利用搜索引擎,这里就不做详细介绍了。
solis search就是基于apache solr开发的一个umbraco的插件。它在做了简单的配置之后,就可以检索到umbraco content里面的几乎所有的文字内容,包括上传的文档或者选择的media picker中的文档(word, pdf, excel 等等)。
下载安装
1. 安装JAVA环境
安装java环境是为了运行apache solr server.
下载地址:http://www.java.com/zh_CN/,
下载后安装,安装之后请配置环境变量,是java命令可以直接在命令行根目录运行。如何配置环境变量在这就不介绍了。
2. 安装apache solr
下载地址:http://lucene.apache.org/solr/,这里记住,一定要下载4.5.1版本的,不然使用会出现未知的错误。因为solis search是基于version 4.5开发的。
请参考官方文档进行安装:http://lucene.apache.org/solr/4_5_1/tutorial.html,
操作简要说明:
- 解压压缩包到电脑的任意位置,建议目录全是英文的
- 打开cmd,进入到目录:solr-4.5.1\example
- 运行> java -jar start.jar启动solr server.
3. 安装 solis search package
下载:https://www.solissearch.com/download/
推荐下载Solis Search 1.1.15.218 Umbraco package, 下载之后再umbraco后台进行安装
安装过程一般不会出错,如果出了错,请下载手动安装包,根据文档进行安装: https://www.solissearch.com/documentation/
安装之后,找到安装包里面的schema.xml和solrconfig.xml然后 复制到solr的文件夹solr-4.5.1\example\solr\collection1\conf\下面,这一步很重要,然后重启solr server: java -jar start.jar
接着就是rebuild index:
当然在rebuild index之前要根据具体的需要修改配置文件。
在这里,我将我的配置贴出来,并且做简单的介绍,
1 <?xml version="1.0"?> 2 <SolisSearch> 3 <SolrServer address="http://localhost:8983/solr" username="" licenseKey="" /> 4 <SearchSettings defaultField="text" enableLanguageSupport="true" enabledLanguages="en" highlight="true" highlightFields="text" fragmenter="regex" fragsize="300" defaultOperator="AND" /> 5 <Languages> 6 <Language name="en" rootNode="1064" /> 7 </Languages> 8 <DocTypes> 9 <DocType name="default" addPageNameToContent="true"> 10 <Properties> 11 <Property name="p1" property="Name" type="text" content="true" /> 12 <Property name="r1" property="relatedLinks" type="relatedLinks" parser="SolisSearch.Parsers.RelatedLinksParser,SolisSearch" /> 13 </Properties> 14 </DocType> 15 <DocType name="umbHomePage"> 16 <Properties> 17 <Property name="p1" property="mainHeading" type="text" content="true" /> 18 <Property name="p2" property="mainContent" type="text" content="true" striphtml="true"/> 19 </Properties> 20 </DocType> 21 <DocType name="newsGroup" addPageNameToContent="true"> 22 <Properties> 23 <Property name="p1" property="Name" type="text" content="true" /> 24 </Properties> 25 </DocType> 26 <DocType name="newsItem" addPageNameToContent="true"> 27 <Properties> 28 <Property name="p1" property="title" type="text" content="true" /> 29 <Property name="p2" property="content" type="text" content="true" striphtml="true"/> 30 <Property name="p3" property="downloadFile" type="relatedLinks" parser="SolisSearch.Parsers.RelatedLinksParser,SolisSearch" /> 31 <Property name="p4" property="uploadDoc" type="relatedLinks" parser="SolisSearch.Parsers.RelatedLinksParser,SolisSearch" /> 32 </Properties> 33 </DocType> 34 </DocTypes> 35 <Facets> 36 <Facet type="value" field="doctypes" mincount="0" sort="false" /> 37 <Facet type="range" field="last_modified" mincount="1"> 38 <Ranges> 39 <FacetRange name="date3" dynamic="thisday" dataType="date" /> 40 <FacetRange name="date4" dynamic="thisweek" dataType="date" /> 41 <FacetRange name="date5" dynamic="thismonth" dataType="date" /> 42 <FacetRange name="date6" dynamic="thisyear" dataType="date" /> 43 <FacetRange name="date7" dynamic="last" gap="20" dataType="date" /> 44 </Ranges> 45 </Facet> 46 </Facets> 47 </SolisSearch>