美文网首页
Solr 安装

Solr 安装

作者: 逸章 | 来源:发表于2020-04-15 10:17 被阅读0次

名词解释:

分面搜索(Faceted Search)--分面是指事物的多维度属性。例如一本书包含主题、作者、年代等分面。而分面搜索是指通过事物的这些属性不断筛选、过滤搜索结果的方法。可以将分面搜索看成搜索和浏览的结合

特性

  • Solr 是作为一个全文检索服务器提供REST-like API.
  • You feed documents into it (which is called indexing) via XML, JSON, CSV, and binary over HTTP.
  • You query it through HTTP GET and receive XML, JSON, CSV, and binary results.

1. 安装

直接下载后解压缩,然后把bin目录加入path中。 注意不需要再单独安装Tomcat和Jetty了

1.1 cloud启动方式

yay@yay-ThinkPad-T470-W10DG:~/software/solr-8.5.0$ solr start -e cloud
...
后面都是采用默认值。注意一下下面这个选项:
Please provide a name for your new collection: [gettingstarted]
...
最后你会看到下面的信息:
SolrCloud example running, please visit: http://localhost:8983/solr

然后Index样例数据,我们这里用的是example/exampledocs/vidcard.xml:

yay@yay-ThinkPad-T470-W10DG:~/software/solr-8.5.0$ bin/post -c gettingstarted example/exampledocs/vidcard.xml/home/yay/software/java/jdk1.8.0_191/bin/java -classpath /home/yay/software/solr-8.5.0/dist/solr-core-8.5.0.jar -Dauto=yes -Dc=gettingstarted -Ddata=files org.apache.solr.util.SimplePostTool example/exampledocs/vidcard.xml
SimplePostTool version 5.0.0
Posting files to [base] url http://localhost:8983/solr/gettingstarted/update...
Entering auto mode. File endings considered are xml,json,jsonl,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log
POSTing file vidcard.xml (application/xml) to [base]
1 files indexed.
COMMITting Solr index changes to http://localhost:8983/solr/gettingstarted/update...
Time spent: 0:00:04.768

1.1.1 用UI访问数据

图片.png

1.1.2 用浏览器访问数据

图片.png

1.1.3 用curl获取数据

yay@yay-ThinkPad-T470-W10DG:~/software/solr-8.5.0$ curl "http://localhost:8983/solr/gettingstarted/select?indent=on&q=*:*"
{
  "responseHeader":{
    "zkConnected":true,
    "status":0,
    "QTime":28,
    "params":{
      "q":"*:*",
      "indent":"on"}},
  "response":{"numFound":48,"start":0,"maxScore":1.0,"docs":[
      {
        "id":"0812521390",
        "cat":["book"],
        "name":["The Black Company"],
        "price":[6.99],
        "inStock":[false],
        "author":["Glen Cook"],
        "series_t":"The Chronicles of The Black Company",
        "sequence_i":1,
        "genre_s":"fantasy",
        "_version_":1664017998565867520},
      {
        "id":"0441385532",
        "cat":["book"],
        "name":["Jhereg"],
        "price":[7.95],
        "inStock":[false],
        "author":["Steven Brust"],
        "series_t":"Vlad Taltos",
        "sequence_i":1,
        "genre_s":"fantasy",
        "_version_":1664017998678065152},
      {
        "id":"0380014300",
        "cat":["book"],
        "name":["Nine Princes In Amber"],
        "price":[6.99],
        "inStock":[true],
        "author":["Roger Zelazny"],
        "series_t":"the Chronicles of Amber",
        "sequence_i":1,
        "genre_s":"fantasy",
        "_version_":1664017998682259456},
      {
        "id":"0805080481",
        "cat":["book"],
        "name":["The Book of Three"],
        "price":[5.99],
        "inStock":[true],
        "author":["Lloyd Alexander"],
        "series_t":"The Chronicles of Prydain",
        "sequence_i":1,
        "genre_s":"fantasy",
        "_version_":1664017998685405184},
      {
        "id":"080508049X",
        "cat":["book"],
        "name":["The Black Cauldron"],
        "price":[5.99],
        "inStock":[true],
        "author":["Lloyd Alexander"],
        "series_t":"The Chronicles of Prydain",
        "sequence_i":2,
        "genre_s":"fantasy",
        "_version_":1664017998687502336},
      {
        "id":"978-0641723445",
        "cat":["book",
          "hardcover"],
        "name":["The Lightning Thief"],
        "author":["Rick Riordan"],
        "series_t":"Percy Jackson and the Olympians",
        "sequence_i":1,
        "genre_s":"fantasy",
        "inStock":[true],
        "price":[12.5],
        "pages_i":384,
        "_version_":1664017998984249344},
      {
        "id":"GB18030TEST",
        "name":["Test with some GB18030 encoded characters"],
        "features":["No accents here",
          "这是一个功能",
          "This is a feature (translated)",
          "这份文件是很有光泽",
          "This document is very shiny (translated)"],
        "price":[0.0],
        "inStock":[true],
        "_version_":1664017999901753344},
      {
        "id":"IW-02",
        "name":["iPod & iPod Mini USB 2.0 Cable"],
        "manu":["Belkin"],
        "manu_id_s":"belkin",
        "cat":["electronics",
          "connector"],
        "features":["car power adapter for iPod, white"],
        "weight":[2.0],
        "price":[11.5],
        "popularity":[1],
        "inStock":[false],
        "store":["37.7752,-122.4232"],
        "manufacturedate_dt":"2006-02-14T23:55:59Z",
        "_version_":1664018001697964032},
      {
        "id":"MA147LL/A",
        "name":["Apple 60 GB iPod with Video Playback Black"],
        "manu":["Apple Computer Inc."],
        "manu_id_s":"apple",
        "cat":["electronics",
          "music"],
        "features":["iTunes, Podcasts, Audiobooks",
          "Stores up to 15,000 songs, 25,000 photos, or 150 hours of video",
          "2.5-inch, 320x240 color TFT LCD display with LED backlight",
          "Up to 20 hours of battery life",
          "Plays AAC, MP3, WAV, AIFF, Audible, Apple Lossless, H.264 video",
          "Notes, Calendar, Phone book, Hold button, Date display, Photo wallet, Built-in games, JPEG photo playback, Upgradeable firmware, USB 2.0 compatibility, Playback speed control, Rechargeable capability, Battery level indication"],
        "includes":["earbud headphones, USB cable"],
        "weight":[5.5],
        "price":[399.0],
        "popularity":[10],
        "inStock":[true],
        "store":["37.7752,-100.0232"],
        "manufacturedate_dt":"2005-10-12T08:00:00Z",
        "_version_":1664018002650071040},
      {
        "id":"adata",
        "compName_s":"A-Data Technology",
        "address_s":"46221 Landing Parkway Fremont, CA 94538",
        "_version_":1664018002680479744}]
  }}

1.2 非cloud方式

1.2.1 启动

yay@yay-ThinkPad-T470-W10DG:~$ source /etc/profile
yay@yay-ThinkPad-T470-W10DG:~$ solr start

1.2.2 创建Core

yay@yay-ThinkPad-T470-W10DG:~$ bin/post -c helloyay example/exampledocs/vidcard.xml

1.2.3 Index数据

yay@yay-ThinkPad-T470-W10DG:~/software/solr-8.5.0$ bin/post -c helloyay example/exampledocs/vidcard.xml

1.2.4 查询

图片.png

相关文章

网友评论

      本文标题:Solr 安装

      本文链接:https://www.haomeiwen.com/subject/jxmqvhtx.html