最新《孔令傑用Python做商管程式設計(一)》
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了最新《孔令傑用Python做商管程式設計(一)》,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含18638字,纯文字阅读大概需要27分钟。
内容图文
![最新《孔令傑用Python做商管程式設計(一)》](/upload/InfoBanner/zyjiaocheng/772/962caac157464b75889e247b81b54827.jpg)
// 1.
GET http://ip:9200/test/test/_search
结果:
{
"took": 86, # 耗费的时间:ms
"timed_out": false, # 是否超时
"_shards": { # 数据存储在5个主分片上
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": { # 匹配结果
"total": 3, # 查询到三个document
"max_score": 1, # 相关度的匹配分数:分数越高越相关
"hits": [
{
"_index": "test", # 索引 index
"_type": "test", # type
"_id": "2", # id:唯一
"_score": 1, # 相关度的匹配分数:分数越高越相关
"_source": { # 存储的json数据
"first_name": "小翠", # field
"last_name": "cuicui",
"age": 18,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
}
},
{
"_index": "test",
"_type": "test",
"_id": "1",
"_score": 1,
"_source": {
"first_name": "John",
"last_name": "Smith",
"age": 25,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
}
},
{
"_index": "test",
"_type": "test",
"_id": "AWrVpGsO0WDJvaOeQOjd",
"_score": 1,
"_source": {
"first_name": "小翠",
"last_name": "cui",
"age": 18,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
}
}
]
}
}
// 2.
GET http://ip:9200/test/test/_search?q=about:climbing&sort=age:desc,price:desc
GET http://ip:9200/test/test/_search?q=about:climbing&sort=age:desc
{
"took": 10,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 3,
"max_score": null,
"hits": [
{
"_index": "test",
"_type": "test",
"_id": "1",
"_score": null,
"_source": {
"first_name": "John",
"last_name": "Smith",
"age": 25,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
},
"sort": [ #排序字段的值
25
]
},
{
"_index": "test",
"_type": "test",
"_id": "2",
"_score": null,
"_source": {
"first_name": "小翠",
"last_name": "cuicui",
"age": 18,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
},
"sort": [
18
]
},
{
"_index": "test",
"_type": "test",
"_id": "AWrVpGsO0WDJvaOeQOjd",
"_score": null,
"_source": {
"first_name": "小翠",
"last_name": "cui",
"age": 18,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
},
"sort": [
18
]
}
]
}
}
// 1.
POST http://ip:9200/test/test/_search
语法:
{
"query":{
"match_all":{}
}
}
结果:
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 5,
"max_score": 1,
"hits": [
{
"_index": "test",
"_type": "test",
"_id": "2",
"_score": 1,
"_source": {
"first_name": "小翠",
"last_name": "cuicui",
"age": 18,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
}
},
{
"_index": "test",
"_type": "test",
"_id": "4",
"_score": 1,
"_source": {
"first_name": "小翠",
"last_name": "cui",
"age": 18,
"price": 15000,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
}
},
{
"_index": "test",
"_type": "test",
"_id": "1",
"_score": 1,
"_source": {
"first_name": "John",
"last_name": "Smith",
"age": 25,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
}
},
{
"_index": "test",
"_type": "test",
"_id": "AWrVpGsO0WDJvaOeQOjd",
"_score": 1,
"_source": {
"first_name": "小翠",
"last_name": "cui",
"age": 18,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
}
},
{
"_index": "test",
"_type": "test",
"_id": "3",
"_score": 1,
"_source": {
"first_name": "小雪",
"last_name": "xiaoxue",
"age": 20,
"about": "climbing",
"interests": [
"dancing",
"music"
]
}
}
]
}
}
// 1.
POST http://ip:9200/test/test/_search
语法:
{
"query":{
"match":{
"about":"climbing"
}
},
"sort":[
{
"age":"desc"
}
]
}
结果:
{
"took": 115,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 5,
"max_score": null,
"hits": [
{
"_index": "test",
"_type": "test",
"_id": "1",
"_score": null,
"_source": {
"first_name": "John",
"last_name": "Smith",
"age": 25,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
},
"sort": [
25
]
},
{
"_index": "test",
"_type": "test",
"_id": "3",
"_score": null,
"_source": {
"first_name": "小雪",
"last_name": "xiaoxue",
"age": 20,
"about": "climbing",
"interests": [
"dancing",
"music"
]
},
"sort": [
20
]
},
{
"_index": "test",
"_type": "test",
"_id": "2",
"_score": null,
"_source": {
"first_name": "小翠",
"last_name": "cuicui",
"age": 18,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
},
"sort": [
18
]
},
{
"_index": "test",
"_type": "test",
"_id": "4",
"_score": null,
"_source": {
"first_name": "小翠",
"last_name": "cui",
"age": 18,
"price": 15000,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
},
"sort": [
18
]
},
{
"_index": "test",
"_type": "test",
"_id": "AWrVpGsO0WDJvaOeQOjd",
"_score": null,
"_source": {
"first_name": "小翠",
"last_name": "cui",
"age": 18,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
},
"sort": [
18
]
}
]
}
}
// 1.
POST http://ip:9200/test/test/_search
语法:
{
"query":{
"bool":{
"must":{
"match":{
"about":"climbing"
}
},
"filter":{
"range":{
"age":{
"gt":20
}
}
}
}
}
}
结果
{
"took": 7,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.26742277,
"hits": [
{
"_index": "test",
"_type": "test",
"_id": "1",
"_score": 0.26742277,
"_source": {
"first_name": "John",
"last_name": "Smith",
"age": 25,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
}
}
]
}
}
POST http://ip:9200/test/test/_search
{
"query":{
"bool":{
"must":{ # 必须匹配
"match":{
"first_name":"小翠"
}
},
"should":{ # 可以匹配,也可以不匹配
"match":{
"last_name": "xue"
}
},
"must_not":{ # 必须不匹配
"match":{
"last_name": "cui"
}
}
}
}
}
// 1.
POST http://ip:9200/test/test/_search
语法:
{
"query":{
"match":{
"about":"go climbing"
}
}
}
分析:es将about这个filed拆解成每个词(term),建立倒排索引,每个term对应相应的document_id
结果:
{
"took": 8,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 7,
"max_score": 0.7447149,
"hits": [
{
"_index": "test",
"_type": "test",
"_id": "2",
"_score": 0.7447149,
"_source": {
"first_name": "小翠",
"last_name": "cuicui",
"age": 18,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
}
},
{
"_index": "test",
"_type": "test",
"_id": "4",
"_score": 0.7447149,
"_source": {
"first_name": "小翠",
"last_name": "cui",
"age": 18,
"price": 15000,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
}
},
{
"_index": "test",
"_type": "test",
"_id": "1",
"_score": 0.61562645,
"_source": {
"first_name": "John",
"last_name": "Smith",
"age": 25,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
}
},
{
"_index": "test",
"_type": "test",
"_id": "AWrVpGsO0WDJvaOeQOjd",
"_score": 0.61562645,
"_source": {
"first_name": "小翠",
"last_name": "cui",
"age": 18,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
}
},
{
"_index": "test",
"_type": "test",
"_id": "5",
"_score": 0.2876821,
"_source": {
"first_name": "花花",
"last_name": "huahau",
"age": 16,
"price": 20000,
"about": "climbing",
"interests": [
"sports",
"music"
]
}
},
{
"_index": "test",
"_type": "test",
"_id": "7",
"_score": 0.25759193,
"_source": {
"about": "go"
}
},
{
"_index": "test",
"_type": "test",
"_id": "3",
"_score": 0.25759193,
"_source": {
"first_name": "小雪",
"last_name": "xiaoxue",
"age": 20,
"about": "climbing",
"interests": [
"dancing",
"music"
]
}
}
]
}
}
// 1.
POST http://ip:9200/test/test/_search
语法:
{
"query":{
"match_phrase":{
"about":"rock climbing"
}
}
}
结果:
{
"took": 20,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 4,
"max_score": 0.9748371,
"hits": [
{
"_index": "test",
"_type": "test",
"_id": "1",
"_score": 0.9748371,
"_source": {
"first_name": "John",
"last_name": "Smith",
"age": 25,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
}
},
{
"_index": "test",
"_type": "test",
"_id": "2",
"_score": 0.7447149,
"_source": {
"first_name": "小翠",
"last_name": "cuicui",
"age": 18,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
}
},
{
"_index": "test",
"_type": "test",
"_id": "4",
"_score": 0.7447149,
"_source": {
"first_name": "小翠",
"last_name": "cui",
"age": 18,
"price": 15000,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
}
},
{
"_index": "test",
"_type": "test",
"_id": "AWrVpGsO0WDJvaOeQOjd",
"_score": 0.6156264,
"_source": {
"first_name": "小翠",
"last_name": "cui",
"age": 18,
"about": "I love to go rock climbing",
"interests": [
"sports",
"music"
]
}
}
]
}
}
内容总结
以上是互联网集市为您收集整理的最新《孔令傑用Python做商管程式設計(一)》全部内容,希望文章能够帮你解决最新《孔令傑用Python做商管程式設計(一)》所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。