#指定英文分词器的index创建
PUT /movie
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1
},
"mappings": {
"properties": {
"name" :{
"type": "text",
"analyzer": "english"
}
}
}
}
#tmdb海量数据测试
DELETE /movie
GET /movie/_search
PUT /movie
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1
},
"mappings": {
"properties": {
"title" :{
"type": "text",
"analyzer": "english"
},
"tagline":{
"type": "text",
"analyzer": "english"
},
"release_date":{
"type": "date",
"format": "8yyyy/MM/dd||yyyy/M/dd||yyyy/MM/d||yyyy/M/d"
},
"popularity":{
"type": "double"
},
"overview":{
"type":"text",
"analyzer": "english"
},
"cast":{
"type": "object",
"properties": {
"character":{
"type":"text",
"analyzer": "standard"
},
"name":{
"type":"text",
"analyzer":"standard"
}
}
}
}
}
}
#搜索 match
GET /movie/_search
{
"query": {
"match": {
"title": "Steve Zissou"
}
}
}
GET /movie/_search
{
"query": {
"term": {
"title": "Steve Zissou"
}
}
}
#查看分词器的分词内容
GET /movie/_analyze
{
"field": "title",
"text":"steve zissou"
}
#分词后or逻辑查询
GET /movie/_search
{
"query": {
"match": {
"title": "basketball with cartoom aliens"
}
}
}
#分词后and 逻辑查询
GET /movie/_search
{
"query": {
"match": {
"title":{
"query": "basketball with cartoom aliens",
"operator": "and"
}
}
}
}
#最小词匹配项,最少有两个分词后的结果匹配
GET /movie/_search
{
"query": {
"match": {
"title":{
"query": "basketball with cartoom aliens",
"operator": "or",
"minimum_should_match": 2
}
}
}
}
#短语查询,不对查询条件进行分词
GET /movie/_search
{
"query": {
"match_phrase": {
"title":"steve zissou"
}
}
}
#多字段查询。对title和overview两个字段进行分词查询
GET /movie/_search
{
"query": {
"multi_match": {
"query": "basketball with cartoom aliens",
"fields": ["title","overview"]
}
}
}
#查看执行计划
GET /movie/_search
{
"explain": true,
"query": {
"match": {
"title": "Steve Zissou"
}
}
}