Coder Social home page Coder Social logo

spring-elasticsearch's Introduction

Getting Started with Spring Elastic Search integration

Application Documentation

  • Start Elastic Search
  • Spring Boot - Elastic Search integration application

below are steps to add records and search by attributes

  • Add a person

POST http://localhost:8080/spring_es/v1/

Content-Type : application/json

request body :

{
    "id": "1",
    "first_name": "sunil",
    "last_name": "kumar",
    "addresses": [
        {
            "address_id": "addr1",
            "address_line1": "33 south 6th steet",
            "address_line2": "6th steet",
            "city": "minneapolis",
            "state_code": "MN",
            "zip_code": "55402"
        }
    ],
    "internet_ids": [
        "[email protected]",
        "sunil@yahoo"
    ]
}

response : person json once successfully saved

  • GET Person by id

GET http://localhost:8080/spring_es/v1/1 response :

{
    "id": "1",
    "first_name": "sunil",
    "last_name": "kumar",
    "addresses": [
        {
            "address_id": "addr1",
            "address_line1": "33 south 6th steet",
            "address_line2": "6th steet",
            "city": "minneapolis",
            "state_code": "MN",
            "zip_code": "55402"
        }
    ],
    "internet_ids": [
        "[email protected]",
        "sunil@yahoo"
    ]
}
  • GET Person by first and last name

GET http://localhost:8080/spring_es/v1/search_by_firstname_lastname?first_name=sunil&last_name=kumar

response

[
    {
        "id": "1",
        "first_name": "sunil",
        "last_name": "kumar",
        "addresses": [
            {
                "address_id": "addr1",
                "address_line1": "33 south 6th steet",
                "address_line2": "6th steet",
                "city": "minneapolis",
                "state_code": "MN",
                "zip_code": "55402"
            }
        ],
        "internet_ids": [
            "[email protected]",
            "sunil@yahoo"
        ]
    }
]
  • fetch list of persons by multiple search attributes that need to match

POST http://localhost:8080/spring_es/v1/search

Content-Type : application/json

request body :

{   
    "first_name": "sunil",
    "last_name": "kumar",
    "internet_ids": "[email protected]",
    "addresses.city": "minneapolis",
    "addresses.zip_code": "55402",
    "addresses.state_code": "MN",
    "addresses.address_id": "addr1",
    "addresses.address_line1": "33 south 6th steet"
}

response

[
    {
        "id": "1",
        "first_name": "sunil",
        "last_name": "kumar",
        "addresses": [
            {
                "address_id": "addr1",
                "address_line1": "33 south 6th steet",
                "address_line2": "6th steet",
                "city": "minneapolis",
                "state_code": "MN",
                "zip_code": "55402"
            }
        ],
        "internet_ids": [
            "[email protected]",
            "sunil@yahoo"
        ]
    }
]
  • fetch list of Persons by any matching attribute

POST http://localhost:8080/spring_es/v1/search_any

Content-Type : application/json

request body :

{
    "first_name": "john",
    "last_name": "kumar"
}

response : (assumption that : John Doe (id = 2) was added) will result in below matching records

[
    {
        "id": "1",
        "first_name": "sunil",
        "last_name": "kumar",
        "addresses": [
            {
                "address_id": "addr1",
                "address_line1": "33 south 6th steet",
                "address_line2": "6th steet",
                "city": "minneapolis",
                "state_code": "MN",
                "zip_code": "55402"
            }
        ],
        "internet_ids": [
            "[email protected]",
            "sunil@yahoo"
        ]
    },
    {
        "id": "2",
        "first_name": "John",
        "last_name": "Doe",
        "addresses": [
            {
                "address_id": "addr1",
                "address_line1": "12000",
                "address_line2": null,
                "city": "minnetonka",
                "state_code": "MN",
                "zip_code": "55305"
            }
        ],
        "internet_ids": [
            "[email protected]",
            "me@yahoo"
        ]
    }
]

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.