This project is used for creating own dynamic elasticsearch filtering API with spring-boot and elasticsearch-java-client
docker-compose.yml
ELASTIC_USERNAME=xyz
ELASTIC_PASSWORD=abcElasticJavaConfig.class
UsernamePasswordCredentials("xyz", "abc")- 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
- 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
}
]
}
}