elasticsearch约定查询
来源:互联网 发布:网络电视直播软件2017 编辑:程序博客网 时间:2024/05/21 06:20
. Query creation
Generally the query creation mechanism for Elasticsearch works as described in Query methods . Here’s a short example of what a Elasticsearch query method translates into:
public interface BookRepository extends Repository<Book, String>{ List<Book> findByNameAndPrice(String name, Integer price);}
The method name above will be translated into the following Elasticsearch json query
{ "bool" : { "must" : [ { "field" : {"name" : "?"} }, { "field" : {"price" : "?"} } ] }}
A list of supported keywords for Elasticsearch is shown below.
And
findByNameAndPrice
{"bool" : {"must" : [ {"field" : {"name" : "?"}}, {"field" : {"price" : "?"}} ]}}
Or
findByNameOrPrice
{"bool" : {"should" : [ {"field" : {"name" : "?"}}, {"field" : {"price" : "?"}} ]}}
Is
findByName
{"bool" : {"must" : {"field" : {"name" : "?"}}}}
Not
findByNameNot
{"bool" : {"must_not" : {"field" : {"name" : "?"}}}}
Between
findByPriceBetween
{"bool" : {"must" : {"range" : {"price" : {"from" : ?,"to" : ?,"include_lower" : true,"include_upper" : true}}}}}
LessThanEqual
findByPriceLessThan
{"bool" : {"must" : {"range" : {"price" : {"from" : null,"to" : ?,"include_lower" : true,"include_upper" : true}}}}}
GreaterThanEqual
findByPriceGreaterThan
{"bool" : {"must" : {"range" : {"price" : {"from" : ?,"to" : null,"include_lower" : true,"include_upper" : true}}}}}
Before
findByPriceBefore
{"bool" : {"must" : {"range" : {"price" : {"from" : null,"to" : ?,"include_lower" : true,"include_upper" : true}}}}}
After
findByPriceAfter
{"bool" : {"must" : {"range" : {"price" : {"from" : ?,"to" : null,"include_lower" : true,"include_upper" : true}}}}}
Like
findByNameLike
{"bool" : {"must" : {"field" : {"name" : {"query" : "?*","analyze_wildcard" : true}}}}}
StartingWith
findByNameStartingWith
{"bool" : {"must" : {"field" : {"name" : {"query" : "?*","analyze_wildcard" : true}}}}}
EndingWith
findByNameEndingWith
{"bool" : {"must" : {"field" : {"name" : {"query" : "*?","analyze_wildcard" : true}}}}}
Contains/Containing
findByNameContaining
{"bool" : {"must" : {"field" : {"name" : {"query" : "?","analyze_wildcard" : true}}}}}
In
findByNameIn(Collection<String>names)
{"bool" : {"must" : {"bool" : {"should" : [ {"field" : {"name" : "?"}}, {"field" : {"name" : "?"}} ]}}}}
NotIn
findByNameNotIn(Collection<String>names)
{"bool" : {"must_not" : {"bool" : {"should" : {"field" : {"name" : "?"}}}}}}
Near
findByStoreNear
Not Supported Yet !
True
findByAvailableTrue
{"bool" : {"must" : {"field" : {"available" : true}}}}
False
findByAvailableFalse
{"bool" : {"must" : {"field" : {"available" : false}}}}
OrderBy
findByAvailableTrueOrderByNameDesc
{"sort" : [{ "name" : {"order" : "desc"} }],"bool" : {"must" : {"field" : {"available" : true}}}}
4.2.3. Using @Query Annotation
@Query
annotation.public interface BookRepository extends ElasticsearchRepository<Book, String> { @Query("{"bool" : {"must" : {"field" : {"name" : "?0"}}}}") Page<Book> findByName(String name,Pageable pageable);}
- elasticsearch约定查询
- elasticsearch 第四篇(API约定)
- solr约定查询名称
- elasticsearch-查询
- Elasticsearch查询
- Elasticsearch查询
- ElasticSearch查询
- Elasticsearch 查询
- elasticsearch-definitive-guide翻译的约定
- Elasticsearch查询配置(Elasticsearch+springboot)
- Elasticsearch- 分词查询
- Elasticsearch- 集群状态查询
- elasticsearch-查询基础篇
- elasticsearch 查询问题
- elasticsearch moreLikeThis查询应用
- ElasticSearch查询字符串
- ElasticSearch结构化查询
- Elasticsearch基础查询
- js的闭包问题
- Linux内核同步
- 200. Number of Islands
- 电脑蓝屏0x0000006B不重装系统的解决办法
- 行动2017—中国软件网团建活动
- elasticsearch约定查询
- JFrame.setDefaultCloseOperation
- 《加密与解密》第三篇解密篇“KeyFile保护攻击”个人实战例子(上)”
- task1 T2 game
- codeforces 632A Grandma Laura and Apples
- U盘装windows系统(大白菜或者是深度软件)
- 随笔
- Solr搜索引擎(4)中文分词器
- Java高并发--重入锁