Giter Club home page Giter Club logo

elastic.js's Introduction

elastic.js can be used with elasticsearch 2.x and lower. There were several breaking changes in the 5.x release for the Query DSL.

You can try elastic-builder for elasticsearch version >= 5.x.

doc is here : https://cdn.rawgit.com/ErwanPigneul/elastic.js/master/dist/docs/ejs.html

elastic.js

A JavaScript implementation of the ElasticSearch DSL for use with the official elasticsearch javascript client.

Documentation

You can find the official documentation at the following locations:

You will also be able to find unofficial documentation and examples on on our blog and GitHub Gist pages here and here.

Examples

Search

See http://www.elasticsearch.org/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-search.

client.search({
  index: 'myindex',
  body: ejs.Request()
          .query(ejs.MatchQuery('title', 'test'))
          .facet(ejs.TermsFacet('tags').field('tags'))
}, function (error, response) {
  // handle response
});

Suggest

See http://www.elasticsearch.org/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-suggest

client.suggest({
  index: 'myindex',
  body: ejs.TermSuggester('mysuggester')
          .text('tset')
          .field('title')
}, function (error, response) {
  // handle suggestion response
});

Multi-Search

See http://www.elasticsearch.org/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-msearch

client.msearch({
  body: [
    {}
    ejs.Request().query(ejs.MatchAllQuery()),
    { index: 'myindex', type: 'mytype' },
    ejs.Request().query(ejs.QueryStringQuery('"Test 1"'))
  ]
});

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.

Also, please don't edit elastic.js and elastic.min.js files as they are generated via grunt. You'll find source code in the "src" subdirectory!

Some tips (memo)

cd docs/ ./build.sh

License

Copyright (c) 2012-2014 FullScale Labs, LLC Licensed under the MIT license.

elastic.js's People

Contributors

mattweber avatar erwanpigneul avatar egaumer avatar phjardas avatar sean-der avatar tillre avatar tomcashman avatar alemures avatar spenceralger avatar karmi avatar bgrainger avatar bruchu avatar vibragiel avatar sudo-suhas avatar vaishaks avatar

Stargazers

Erik avatar Pavan Kunisetty avatar Boris Cosic avatar Oğuz Çelikdemir avatar Benjamin Doherty avatar Antoine Lambert avatar Matheus Candido avatar  avatar Girla avatar Alireza avatar Francesco Furiani avatar Suhas Karanth avatar  avatar Mark Herhold avatar Nima Jalali avatar 饶琛琳 avatar Justin Stayton avatar Boris Jonica avatar Adrian Rossouw avatar Raja Venkataraman avatar Alison Rowland avatar Simon Kerler avatar

Watchers

James Cloos avatar 饶琛琳 avatar  avatar Faucogney Anthony avatar

elastic.js's Issues

The documentation for `MultiMatchQuery#minimumShouldMatch` says it outputs percentages, but does integers:

First, thanks for the fork!

I wanted to report the following issue:

The documentation is not according with the code

It claims that MultiMatchQuery#minimumShouldMatch:

Sets a percent value controlling how many "should" clauses in the resulting Query should match.

and that the:

Parameters
minMatch An integer between 0 and 100.

but is not the case.
Once the function is called with an integer parameter, the output JSON for that field is an integer, and not the expected percentage.

{ multi_match:
   { query: 'test_query',
     fields: [ 'test_field' ],
     minimum_should_match: 4 } }

The api for [minimum-should-match in the es documentation](https://www.elastic.co/guide/en/elasticsearch/reference/1.4/query-dsl-minimum- +should-match.html) distinguishes the case for:

Type Example Description
Integer 3 Indicates a fixed value regardless of the number of optional clauses.
Percentage 75% Indicates that this percent of the total number of optional clauses are necessary. The number computed +from the percentage is rounded down and used as the minimum.

If my analysis is correct, the documentation could be updated, describing that it is accepted a String representing any of the minimum_should_match options

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.