|
@@ -3,6 +3,7 @@ package es
|
|
import (
|
|
import (
|
|
"log"
|
|
"log"
|
|
"testing"
|
|
"testing"
|
|
|
|
+ // es "github.com/olivere/elastic/v7"
|
|
)
|
|
)
|
|
|
|
|
|
type AggregationsBucket struct {
|
|
type AggregationsBucket struct {
|
|
@@ -15,70 +16,26 @@ type AggregationsBucket struct {
|
|
|
|
|
|
func TestGet(t *testing.T) {
|
|
func TestGet(t *testing.T) {
|
|
q := `{
|
|
q := `{
|
|
- "query": {
|
|
|
|
- "bool": {
|
|
|
|
- "must": [
|
|
|
|
- {
|
|
|
|
- "bool": {
|
|
|
|
- "should": [
|
|
|
|
- {
|
|
|
|
- "terms": {
|
|
|
|
- "subtype": [
|
|
|
|
- "拟建"
|
|
|
|
- ]
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- "terms": {
|
|
|
|
- "toptype": [
|
|
|
|
- "预告",
|
|
|
|
- "招标",
|
|
|
|
- "结果",
|
|
|
|
- "其它"
|
|
|
|
- ]
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- ]
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- ],
|
|
|
|
- "must_not": []
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- "_source": [
|
|
|
|
- "_id",
|
|
|
|
- "title",
|
|
|
|
- "publishtime",
|
|
|
|
- "toptype",
|
|
|
|
- "subtype",
|
|
|
|
- "type",
|
|
|
|
- "area",
|
|
|
|
- "dataweight",
|
|
|
|
- "city",
|
|
|
|
- "s_subscopeclass",
|
|
|
|
- "bidamount",
|
|
|
|
- "budget",
|
|
|
|
- "buyerclass",
|
|
|
|
- "spidercode",
|
|
|
|
- "site",
|
|
|
|
- "filetext",
|
|
|
|
- "isValidFile"
|
|
|
|
- ],
|
|
|
|
- "sort": [
|
|
|
|
- {
|
|
|
|
- "dataweight": "desc"
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- "publishtime": "desc"
|
|
|
|
- }
|
|
|
|
- ],
|
|
|
|
- "from": 1,
|
|
|
|
- "size": 50
|
|
|
|
-}`
|
|
|
|
|
|
+ "query": {
|
|
|
|
+ "bool": {
|
|
|
|
+ "must": [
|
|
|
|
+ {
|
|
|
|
+ "multi_match": {
|
|
|
|
+ "query": "维护",
|
|
|
|
+ "type": "phrase",
|
|
|
|
+ "fields": [
|
|
|
|
+ "title"
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ },"size":3
|
|
|
|
+ }`
|
|
NewEs("v7", "http://192.168.3.241:9205,http://192.168.3.149:9200", 2, "", "")
|
|
NewEs("v7", "http://192.168.3.241:9205,http://192.168.3.149:9200", 2, "", "")
|
|
//NewEs("v1", "http://192.168.3.206:9800", 2, "", "")
|
|
//NewEs("v1", "http://192.168.3.206:9800", 2, "", "")
|
|
- count, _ := GetWithCount("bidding", "bidding", "", q)
|
|
|
|
- log.Println(count)
|
|
|
|
|
|
+ list := Get("bidding", "bidding", q)
|
|
|
|
+ log.Println(list)
|
|
}
|
|
}
|
|
|
|
|
|
func TestAnalyze(t *testing.T) {
|
|
func TestAnalyze(t *testing.T) {
|
|
@@ -87,3 +44,24 @@ func TestAnalyze(t *testing.T) {
|
|
res := Analyze("软件中国", "bidding", "ik_smart")
|
|
res := Analyze("软件中国", "bidding", "ik_smart")
|
|
log.Println(res)
|
|
log.Println(res)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+func TestScroll(t *testing.T) {
|
|
|
|
+ NewEs("v7", "http://192.168.3.149:9200", 2, "", "")
|
|
|
|
+ q := `{
|
|
|
|
+ "query": {
|
|
|
|
+ "bool": {
|
|
|
|
+ "must": {
|
|
|
|
+ "range": {
|
|
|
|
+ "pici": {
|
|
|
|
+ "gt": 1686041829,
|
|
|
|
+ "lte": 1716450097
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },"_source":["id"]
|
|
|
|
+ }`
|
|
|
|
+ VarEs.(*EsV7).Scroll("projectset", "5m", q, func(fv map[string]interface{}) {
|
|
|
|
+ log.Println(fv)
|
|
|
|
+ })
|
|
|
|
+}
|