zoukankan      html  css  js  c++  java
  • lucene-SpanNotQuery和SpanOrQuery交迭与全局跨度

    1、在匹配结果中排除相互交迭的跨度

    SpanNotQuery构造函数的第一个参数表示要包含的跨度对象,第二个参数表示要排除的跨度对象。

    1)

    SpanNearQuery quick_fox=new SpanNearQuery(new SpanQuery[]{quick,fox},1,true);

    dumpSpans查询时输出

    the <quick brown fox> jumps over the lazy dog (0.18461232)

    the <quick red fox> jumps over the sleep cat (0.18461232)

    2)

    SpanNotQuery quick_fox_dog=new SpanNotQuery(quick_fox,dog);

    dumpSpans查询时输出

    the <quick brown fox> jumps over the lazy dog (0.18461232)

    the <quick red fox> jumps over the sleep cat (0.18461232)

    3)只匹配了第一个文档,因为第二个文档包括red

    SpanNotQuery no_quick_red_fox=new SpanNotQuery(quick_fox,red);

    dumpSpans查询时输出

    the <quick red fox> jumps over the sleep cat (0.18461232)

    2、SpanOrQuery,在构造函数中对一个SpanQuery对象的集合进行封装

    1)

    SpanNearQuery qf_near_ld=new SpanNearQuery(new SpanQuery[]{quick_fox,lazy_dog},3,true);

    dumpSpans查询时输出

    the <quick brown fox jumps over the lazy dog> (0.38461232)

    2)

    SpanNearQuery qf_near_sc=new SpanNearQuery(new SpanQuery[]{quick_fox,sleep_cat},3,true);

    dumpSpans查询时输出

    the <quick red fox jumps over the sleep cat> (0.38461232)

    3)查询这样一些文档,这些文档或者包括"quick fox" near "lazy dog"或者包括"quick fox" near "sleep cat"

    dumpSpans查询时输出

    the <quick brown fox jumps over the lazy dog> (0.38461232)

    the <quick red fox jumps over the sleep cat> (0.38461232)

  • 相关阅读:
    n年的一次聚会
    maven用途、核心概念、用法、常用参数和命令、扩展
    iOS系统架构和Object-C基本数据类型(1)
    Object-C类、方法、构造函数(2)
    iOS 【资源篇】
    iOS播放视频
    蘑菇街 IM 项目 TeamTalk
    Extjs5.0 学习之路【结构篇】
    Hibernate基础(一)
    C# Winform中无焦点状态下获取键盘输入或者USB扫描枪数据
  • 原文地址:https://www.cnblogs.com/1130136248wlxk/p/5031089.html
Copyright © 2011-2022 走看看