Giter Club home page Giter Club logo

elasticsearch-fql's Introduction

Elasticsearc FastQueryLanguage compatible plugin

fql

Fastの検索文をelasticsearchに置き換えて検索するplugin 検索結果もFastの検索結果に近い形でxmlで出力されます。

全ての機能をカバーしてはいません。 私に必要な機能のみを実装していますwww

Query and Result Protocol Specification http://download.microsoft.com/download/3/4/C/34C47498-E69F-4CEF-9B58-5CEB77E1553D/[MS-FSQR].pdf Fast Query Language Version 2 Protocol http://interoperability.blob.core.windows.net/files/MS-FQL2/[MS-FQL2].pdf

build

gradle assemble

install

bin/elasticsearch-plugin install file:///path/to/elasticsearch-fql.zip

検索

request

GET _fast/{index}/{tyoe}/search?qyerty=and(field:"xxx",id:1)

response

<SEGMENTS>
  <SEGMENT NAME="webcluster">
    <RESULTPAGE>
      <QUERYTRANSFORMS>
        <QUERYTRANSFORM NAME="Original query" ACTION="NOP" CUSTOM="" MESSAGE="Original query" MESSAGEID="1" QUERT="and(field:&quot;xxx&quot;,id:1)"/>
        <QUERYTRANSFORM NAME="FastQT Kansuji" ACTION="nop" CUSTOM="" MESSAGE="Query was not modified." MESSAGEID="2" INSTANCE="kansuji" QUERY="Trere were no CJK numerals in the query."/>
        <QUERYTRANSFORM NAME="FastQT_Lemmatizer" ACTION="nop" CUSTOM="No change to query" MESSAGE="Lemmatization turned off for current query" MESSAGEID="16" INSTANCE="lemmatizer" QUERY=""/>
        <QUERYTRANSFORM NAME="Final query" ACTION="NOP" CUSTOM="" MESSAGE="Final query" MESSAGEID="1" QUERY=""/>
      </QUERYTRANSFORMS>
      <NAVIGATION ENTRIES="0"/>
      <CLUSTERS/>
      <RESULTSET TOTALHITS="1" FIRSTHIT="1" HITS="1" LASTHIT="1" MAXRANK="0" TIME="342ms">
        <HIT NO="1" FCOCOUNT="0" MOREHITS="0" RANK="0" SITEID="0">
          <FIELD name="field">xxx</FIELD>
          <FIELD name="id">1</FIELD>
        </HIT>
      </RESULTSET>
      <PAGENAVIGATION/>
    </RESULTPAGE>
  </SEGMENT>
</SEGMENTS>

Parameters

Name Description
query 検索文字列 FQLにて指定
sortby ソートを条件を指定 単純なfield毎のASC/DESCの指定のみ可能
navigation filter queryに置き換えます
offset 検索結果の開始位置 default 0
hits 検索数 default 10

NAVIGATION

FASTのNAVIGATION(Elasticsearchで言う所のAggregation)はスキーマの定義にて行います。 本実装では、Aggregstionの定義を保存し、検索実行時に自動で付与して結果を返します。 index/type毎に一つのNAVIGATIONを指定可能 情報はElasticsearch状の.fastインデックスに格納される。

request

検索結果に付与するAggregationの条件を設定

PUT /_fast/test/type/_navigation
{ "aggs" : { "fields" : { "terms" : { "field" : "field" , "size":2} } } }

response

{
  "_index" : ".fast",
  "_type" : "dGVzdA==",
  "_id" : "dHlwZQ==",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 0,
  "_primary_term" : 1
}

検索結果

request

GET _fast/{index}/{tyoe}/search?qyerty=field:"xxx"

response

結果にが追加されている。

<SEGMENTS>
  <SEGMENT NAME="webcluster">
    <RESULTPAGE>
      <QUERYTRANSFORMS>
        <QUERYTRANSFORM NAME="Original query" ACTION="NOP" CUSTOM="" MESSAGE="Original query" MESSAGEID="1" QUERT="field:&quot;xxx&quot;"/>
        <QUERYTRANSFORM NAME="FastQT Kansuji" ACTION="nop" CUSTOM="" MESSAGE="Query was not modified." MESSAGEID="2" INSTANCE="kansuji" QUERY="Trere were no CJK numerals in the query."/>
        <QUERYTRANSFORM NAME="FastQT_Lemmatizer" ACTION="nop" CUSTOM="No change to query" MESSAGE="Lemmatization turned off for current query" MESSAGEID="16" INSTANCE="lemmatizer" QUERY=""/>
        <QUERYTRANSFORM NAME="Final query" ACTION="NOP" CUSTOM="" MESSAGE="Final query" MESSAGEID="1" QUERY=""/>
      </QUERYTRANSFORMS>
      <NAVIGATION ENTRIES="1">
        <NAVIGATIONENTRY NAME="fields" DISPAYNAME="fields" MODIFIER="fields">
          <NAVIGATIONELEMENTS COUNT="1">
            <NAVIGATIONELEMENT NAME="xxx" MODIFIER="^&quot;xxx&quot;$" COUNT="2"/>
          </NAVIGATIONELEMENTS>
        </NAVIGATIONENTRY>
      </NAVIGATION>
      <CLUSTERS/>
      <RESULTSET TOTALHITS="2" FIRSTHIT="1" HITS="2" LASTHIT="2" MAXRANK="0" TIME="275ms">
        <HIT NO="1" FCOCOUNT="0" MOREHITS="0" RANK="0" SITEID="0">
          <FIELD name="field">xxx</FIELD>
          <FIELD name="id">1</FIELD>
        </HIT>
        <HIT NO="2" FCOCOUNT="0" MOREHITS="0" RANK="0" SITEID="0">
          <FIELD name="field">xxx</FIELD>
          <FIELD name="id">3</FIELD>
        </HIT>
      </RESULTSET>
      <PAGENAVIGATION/>
    </RESULTPAGE>
  </SEGMENT>
</SEGMENTS>

elasticsearch-fql's People

Contributors

animalmatsuzawa avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.