我正在尝试使用MsSQL进行弹性搜索 但我找不到任何结果
表名是Orders_Table 这些字段是[OrderID],[CustomerName],[UserFullName],[Status]
第1步:构建索引
POST /_river/mytest_river/_meta
{
"type":"jdbc",
"jdbc":
{
"driver":"com.microsoft.sqlserver.jdbc.SQLServerDriver",
"url":"jdbc:sqlserver://[my_ip];databaseName=mega",
"user":"sa","password":"******",
"sql":"SELECT [OrderID],[CustomerName],[UserFullName],[Status] FROM [Orders_Table]",
"poll":"5s",
"index": "mega",
"type": "orders_table"
}
}
结果
{
"_index": "_river",
"_type": "mytest_river",
"_id": "_meta",
"_version": 2,
"created": false
}
第2步:映射
PUT /_river/_mappings/orders_table
{
"orders_table" : {
"properties" : {
"OrderID" : {"type" : "integer"},
"CustomerName" : {"type" : "string" },
"UserFullName" : {"type" : "string" },
"Status" : {"type" : "string" }
}
}
}
结果
{
"acknowledged": true
}
第3步:_search
POST /_river/mytest_river/_search
{
"query": {
"multi_match": {
"query": "7694964",
"fields": [ "OrderID" ]
}
}
}
结果
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
为什么找不到行[OrderID] = 7694964 ?
为什么点击次数为0 ??
如何将表格结果改为命中?
答案 0 :(得分:1)
尝试
POST /mega/orders_table/_search
{
"query": {
"multi_match": {
"query": "7694964",
"fields": [ "OrderID" ]
}
},
"size": 100
}
获取100个文档或使用scan and scroll获取分页结果,甚至使用from/size获取相同内容。但是,要小心size
,您不希望在那里设置大值,因为它可能会降低您的群集。如果您有许多文档,最好的方法是使用扫描和滚动。