Easy-Es Easy-Es
💋Home
  • v2.0.0(current version)
  • What's New

    • What' s New In Easy-Es v2.0.0?
  • history version

    • v1.x.x
  • Upgrade guide

    • Upgrade to 2.x.x instructions
💖Support
  • OS Community
  • Recommend Goods
  • Project PPT (opens new window)
  • Project introduction
  • Project members
  • PR
Join
Customer
  • Doc-Apis (opens new window)
  • Fitness plan automatic generation system (opens new window)
  • Vuepress-theme-vdoing (opens new window)
  • Gitee (opens new window)
  • Github (opens new window)
  • 简体中文 (opens new window)
  • English (opens new window)

adv display by random ❤️become sponsor
💋Home
  • v2.0.0(current version)
  • What's New

    • What' s New In Easy-Es v2.0.0?
  • history version

    • v1.x.x
  • Upgrade guide

    • Upgrade to 2.x.x instructions
💖Support
  • OS Community
  • Recommend Goods
  • Project PPT (opens new window)
  • Project introduction
  • Project members
  • PR
Join
Customer
  • Doc-Apis (opens new window)
  • Fitness plan automatic generation system (opens new window)
  • Vuepress-theme-vdoing (opens new window)
  • Gitee (opens new window)
  • Github (opens new window)
  • 简体中文 (opens new window)
  • English (opens new window)
  • Quick start

    • Introduction.md
    • Applicable scene
    • Worry free
    • Avoid pit
    • Quick start
    • Springboot demo
    • Spring Integration Guide
    • Solon Integration Guide
    • Config
    • Annotation
  • Core function

    • Condition constructor

      • Introduction of Wrapper
      • Index wrapper
      • Select wrapper
      • Update wrapper
    • Index CRUD

      • Index hosting model
      • Index CRUD
    • Data CRUD

      • Data synchronization solutions
      • Data CRUD
    • Multiple data sources support
    • Dynamic indexing support
    • Four nested query
    • Chain call
  • Extended function

    • Mixed query
    • Origin query
    • Page
    • Nested
    • Join parent child
    • Get DSL
    • ExecuteDSL
    • Execute SQL
    • Custom RequestOptions
    • Custom default method
  • High-level syntax

    • Field filtering
    • Sort
    • Aggregation
    • Match&fuzzy match
    • Weight
    • Highlight
    • Geo
    • IP
      • IP
      • best practices
  • Plugin

    • Plugin
  • Other

    • Faq
    • Difference from MP
    • MySQL and EE syntax comparison
    • Update log
    • Update plan
    • Copyright
    • Thanks
  • v2.xDoc
  • High-level syntax
LaoHan
2023-03-18
目录

IP

# IP

提示

ES itself has a very friendly support for IP queries, so it is very suitable for storing and querying IP, it is worth noting that the index type of the field corresponding to IP must be established as ip type, not is text, keyword or default type, otherwise you will find in the later query you do not want to achieve the IP range search.

# best practices

public class Document{
    // Omit other fields...
    @IndexField(fieldType = FieldType.IP)
    private String ipAddress;
}
1
2
3
4
5

Add, delete and other types of fields are not the same, no longer demonstrate, assuming I have entered an ip address of "192.168.1.1" to es

    @Test
    public void testIp(){
        // Precise query
        LambdaEsQueryWrapper<Document> wrapper = new LambdaEsQueryWrapper<>();
        wrapper.eq(Document::getIpAddress, "192.168.1.1");
        List<Document> documents = documentMapper.selectList(wrapper);
        
        // Range search
        LambdaEsQueryWrapper<Document> wrapper1 = new LambdaEsQueryWrapper<>();
        wrapper1.eq(Document::getIpAddress, "192.168.0.0/16");
        List<Document> documents1 = documentMapper.selectList(wrapper);
        
        // ip fuzzy match es not supported
    }
1
2
3
4
5
6
7
8
9
10
11
12
13
14

For the above IPv4 IP address contains 4 bytes, and each byte contains 8 digits, in the above /16 that means the front 16 digits, that is, 192.168, so as long as the IP is located in 192.168.0.0 to 192.168.255.255 can be retrieved by the above search criteria.

Help us improve this document (opens new window)
Last update: 2024/03/29
Geo
Plugin

← Geo Plugin→

Theme by Vdoing | Copyright © 2021-2025 LaoHan | Zhejiang ICP No. 2022020479 | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式