美文网首页
solr基础练习

solr基础练习

作者: 不会唱歌的我 | 来源:发表于2017-06-07 17:01 被阅读0次

    1理解索引

    1.1定位 techproducts 内核所在的文件目录

    主要有两个文件,conf和data

    conf:主要用于存放core的配置文件,

    (1)、schema.xml用于定义索引库的字段及分词器等,这个配置文件是核心文件
    (2)、solrconfig.xml定义了这个core的配置信息,比如:
    <autoCommit>
    <maxTime>15000</maxTime>
    <openSearcher>false</openSearcher>
    </autoCommit>
    定义了什么时候自动提交,提交后是否开启一个新的searcher等等。

    data:主要用于存放core的数据,即index-索引文件和log-日志记录

    1.2定位solr索引文件位置

    Index:/opt/solr-6.3.0/example/techproducts/solr/techproducts/data/index
    

    1.3 下载索引数据到本地

    直接按照路径在终端上下载index文件夹

    1.4使用 Luke 查看索引数据

    Luke是一个方便的索引查看和诊断工具,可以访问Lucene构建的索引文件,显示和修改某些索引内容。能提供:

    •通过document编号或term浏览索引
    •查看document内容,可复制到剪贴板
    •对频率最高的term的索引字段提供排名后的浏览
    •执行搜索语句并浏览搜索结果
    •分析搜索结果
    •从索引中选择性删除文件
    •重建原始文档字段,对其进行编辑,然后重新插入的索引
    •优化索引
    •可以打开hadoop文件系统内的索引文件

    在 searchsearch search选项卡中, 选项卡中 搜索 name :ipod ipod
    ![2.GIF](https://img.haomeiwen.com/i5876474/f074107fb576ce80.GIF?imageMogr2/auto-orient/strip)

    2.掌握query查询构造

    2.1搜索制造商为 Belkin的 iPod配件,搜索结果按价格升序排列,搜索结果内容包含名称 (name )、价格( price )、特征 (features features ),返回 xml 数据 。
    http://120.24.46.77:8983/solr/techproducts/select?fl=name price features&indent=on&q=Belkin&sort=price asc&wt=xml
    
    Paste_Image.png
    2.2搜索流行度为 5以上的产品
    http://120.24.46.77:8983/solr/techproducts/select?fl=name,price,popularity&fq=popularity:[5 TO *]&indent=on&q=*:*&rows=5&wt=xml
    
    Paste_Image.png
    2.3 搜索价格在 400 以下且有存库的商品
    http://120.24.46.77:8983/solr/techproducts/select?fl=name,price,features,score&fq=price:[* TO 400]&indent=on&q=*:*&sort=popularity asc&wt=xml
    
    Paste_Image.png
    2.4 在特征 ( features )字段中搜索“ plays ”
    http://120.24.46.77:8983/solr/techproducts/select?fq=features:plays&hl.fl=plays&hl=on&indent=on&q=*:*&wt=xml
    

    ![Uploading Paste_Image_996077.png . . .]


    Paste_Image.png

    相关文章

      网友评论

          本文标题:solr基础练习

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