GithubHelp home page GithubHelp logo

challenge-elasticsearch's Introduction

Search Tool

Challenge

Develop a tool that allows searching for a keyword in a set of +11,800 text files.

Requirements

  • Coverage of unit tests.
  • Versioned code.
  • Documentation to execute the code tool.
  • The keyword search doesn't have a logical order.
  • When a keyword is composed, the search criteria must be AND.
  • Process executed up to 1ms.
  • The set of files can be pre-processed.

Architecture

Architecture

Project structure

Initial considerations

The developed tool has a structure to be executed and the allowed commands are described below:

Option First Argument Second Argument Example Consider
upload index-name path upload my-index "./data" the second argument must be contained in double quotes
search index-name keyword search my-index "walt disney" the index-name must be the same that was used to upload the files
native-search index-name keyword native-search my-index "julian" the index-name must be the same that was used to upload the files

How to prepare the environment?

Step 01

Run the docker-compose.yml file with the command:

docker-compose up -d

We can now access ElasticSearch and Kibana instances at http://localhost:9200 and http://localhost:5601 respectively.

In case you don't have Docker installed, use this tutorial.

Step 02

Populate the ElasticSearch instance with information from the text files found in the ./data.

This process can be executed through the tool with the command:

java -jar bulksearch-app.jar upload <index-name> "./data"

Don't forget to remove the '<>' characters and change to the correct index.

How to run a search?

You have two options to perform a search:

Option 01

Run the next command to search with Elasticsearch Java API Client

java -jar bulksearch-app.jar search <index-name> "walt disney"

Option 02

Run the next command to search with Rest native request

java -jar bulksearch-app.jar native-search <index-name> "walt disney"

The result for both queries will have the same result, the only difference is the response speed.

Result with search option

Result Of Search

Result with native-search option

Result Of Native-Search


Technical section

Stack

Technology Using
My Skills Build application
My Skills Run commands
My Skills Prepare environment
Index data

Running unit tests

Result Of Search

Ejecuta vĂ­a comando las pruebas unitarias con el siguiente comando:

> cd ./unit-test
> java -cp "junit-4.13.2.jar;." org.junit.runner.JUnitCore <ClassNameToTest>

Query used to retrieve data

get /index-name/_search
{
  "_source": ["field-to-search"],
  "query": {
    "match": {
      "content": {
        "query": "words keys",
        "operator": "and"
      }
    }
  },"sort": [
    {
      "title": {
        "order": "asc"
      }
    }
  ]
}

challenge-elasticsearch's People

Contributors

saenzjulian avatar

Watchers

 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.