Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SPRING-ELASTICSEARCH-CUSTOM-FILTERING APP

This project is used for creating own dynamic elasticsearch filtering API with spring-boot and elasticsearch-java-client

Change Me

docker-compose.yml

      ELASTIC_USERNAME=xyz
      ELASTIC_PASSWORD=abc

ElasticJavaConfig.class

UsernamePasswordCredentials("xyz", "abc")

Description link

MEDIUM

Dependencies

  • java - 17
  • spring-boot-starter-parent - 3.4.1
  • spring-boot-starter-data-elasticsearch - 3.4.5
  • elasticsearch-java - 8.17.0
  • image - docker.elastic.co/elasticsearch/elasticsearch - 8.7.1

Usage Examples

  • With pageInfo and equals filter
{
  "filters": {
    "filterList": [
      {
        "property": "productTags",
        "queryCommand": "EQUALS",
        "value": "car"
      }
    ],
    "pageInfo": {
      "pageNumber": 0,
      "pageSize": 10,
      "sortList": [
        "productId"
      ],
      "direction": "DESC"
    }
  }
}
  • Without pageInfo and equals filter
{
  "filters": {
    "filterList": [
      {
        "property": "productTags",
        "queryCommand": "EQUALS",
        "value": "car"
      }
    ]
  }
}
  • not equals filter
{
  "filters": {
    "filterList": [
      {
        "property": "productTags",
        "queryCommand": "NOT_EQUALS",
        "value": "test"
      }
    ]
  }
}
  • like filter
{
  "filters": {
    "filterList": [
      {
        "property": "sellers.locations",
        "queryCommand": "LIKE",
        "value": "kar"
      }
    ]
  }
}
  • start with filter
{
  "filters": {
    "filterList": [
      {
        "property": "sellers.locations",
        "queryCommand": "START_WITH",
        "value": "an"
      }
    ]
  }
}
  • lt filter
{
  "filters": {
    "filterList": [
      {
        "property": "sellers.price",
        "queryCommand": "LT",
        "value": 100
      }
    ]
  }
}
  • gt filter
{
  "filters": {
    "filterList": [
      {
        "property": "sellers.price",
        "queryCommand": "GT",
        "value": 5
      }
    ]
  }
}
  • between filter
{
  "filters": {
    "filterList": [
      {
        "property": "sellers.price",
        "queryCommand": "BETWEEN",
        "value": {
          "min": 5,
          "max": 20
        }
      }
    ]
  }
}
  • date range filter
{
  "filters": {
    "filterList": [
      {
        "property": "manufactureDate",
        "queryCommand": "DATE_RANGE",
        "value": {
          "startDate": "2025-05-20T00:00:00.000",
          "endDate": "2025-05-30T00:00:00.000"
        }
      }
    ]
  }
}
  • IN filter
{
  "filters": {
    "filterList": [
      {
        "property": "sellers.locations",
        "queryCommand": "IN",
        "value": [
          "london",
          "paris",
          "istanbul"
        ]
      }
    ]
  }
}
  • IN LIKE filter
{
  "filters": {
    "filterList": [
      {
        "property": "sellers.locations",
        "queryCommand": "IN_LIKE",
        "value": [
          "don",
          "ris"
        ]
      }
    ]
  }
}
  • combine filter
{
  "filters": {
    "filterList": [
      {
        "property": "sellers.locations",
        "queryCommand": "IN_LIKE",
        "value": [
          "kar"
        ]
      },
      {
        "property": "accessories.price",
        "queryCommand": "LT",
        "value": 50
      }
    ]
  }
}

Developer

SERDAR ALKAN

mail info

About

create custom filter API for spring boot and elasticsearch-java-client app

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages