Giter Site home page Giter Site logo

mastering-elasticsearch-5.x-third-edition's Introduction

Mastering Elasticsearch 5.x - Third Edition

This is the code repository for Mastering Elasticsearch 5.x - Third Edition, published by Packt. It contains all the supporting project files necessary to work through the book from start to finish.

About the Book

This book will give you a brief recap of the basics and also introduce you to the new features of Elasticsearch 5. We will guide you through the intermediate and advanced functionalities of Elasticsearch, such as querying, indexing, searching, and modifying data. We’ll also explore advanced concepts, including aggregation, index control, sharding, replication, and clustering. ##Instructions and Navigation All of the code is organized into folders. Each folder starts with a number followed by the application name. For example, Chapter02.

Chapters 1 and 8 do not have downloadable code or support files They contain simple commands

The code will look like the following:

public class CustomRestActionPlugin extends Plugin implements ActionPlugin
{
 @Override
 public List<Class<? extends RestHandler>> getRestHandlers() {
 return Collections.singletonList(CustomRestAction.class);
 }
}

This book was written using Elasticsearch 5.0.x, and all the examples and functions should work with it. In addition to that, you'll need a command-line tool that allows you to send HTTP requests such as curl, which are available for most operating systems. Please note that all examples in this book use the mentioned curl tool. If you want to use another tool, please remember to format the request in an appropriate way that is understood by the tool of your choice. In addition to that, to run examples in Chapter 11, Developing Elasticsearch Plugins, you will need a Java Development Kit (JDK) Version 1.8.0_73 and above installed and an editor that will allow you to develop your code (or a Java IDE such as Eclipse). To build the code and manage dependencies in Chapter 11, Developing Elasticsearch Plugins, we are using Apache Maven. The last chapter of this book has been written using Elastic Stack 5.0.0, so you will need to have Logstash, Kibana, and Metricbeat, all comprising the same version.

Related Products

Suggestions and Feedback

Click here if you have any feedback or suggestions.

mastering-elasticsearch-5.x-third-edition's People

Contributors

packt-itservice avatar packtprasadr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mastering-elasticsearch-5.x-third-edition's Issues

Implementing a document read counter by user using painless

@packtprasadr
I came across your repo while searching for painless examples. As you know, the documentation and examples on elastic's own site are few and far between.

As per this forum post some months ago, I had been trying to solve this with painless, but had no joy in solving. I wonder if you would have some sense for how this could be accomplished with painless. It might make a good example for one of your chapters!

I'll regenerate the initial description from the forum thread here:

I have a document with a nested 'views' field, containing a 'user' and a 'count' value.

"views": 
[{"count": 2,
"user": "tt99"},
{"count":1,
"user: "tt88"}]

I'm trying to figure out a 'painless' script that, depending on the supplied parameters, either:
(a) adds the field "views", along with a user and default count of 1, when the field does not pre-exist;
(b) where the field does pre-exist, it appends the new user and a default count of 1 to the views array; or
(c) where both the field and user pre-exist, it just increments the counter by one, but doesn't duplicate the user.

I have tried this (which I know doesn't handle the field not pre-existing):

POST index/type/12345/_update
{
"script": {
"lang": "painless",
"inline": "if (ctx.source.views.user === params.view.user) {ctx.source.views.count += params.view.count} else {ctx._source.views += params.view}",
"params": {
"view": {"user":"tt99", "count":1}
}
}
}

However, it doesn't like how I am reference user: "Illegal list shortcut value [user]."

In the case above, I would expect, as my result, the count to increment to 3. If my params were {"user":"tt77", "count":1}, I would expect a new user "tt77" with count of 1 to get appended to the views array.

Should I be somehow looping through the json docs within the views array? I have seen a groovy example referencing a 'containskey' function .. but I tried that in 'painless' without any joy. You can see the thread for a few other approaches I took, but none appear to work. I would be curious if have an alternative approach that might work.

Thanks.

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.