search.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. package es
  2. import (
  3. "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXCore/rpc/bxcore"
  4. "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXCore/rpc/entity"
  5. IC "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXCore/rpc/init"
  6. "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXCore/rpc/util"
  7. "fmt"
  8. "strconv"
  9. "strings"
  10. "time"
  11. MC "app.yhyue.com/moapp/jybase/common"
  12. elastic "app.yhyue.com/moapp/jybase/es"
  13. "log"
  14. )
  15. // GetSearchQuery 整理关键词等查询条件
  16. func GetSearchQuery(in *bxcore.SearchReq, mustQuery string) (qstr string) {
  17. var (
  18. //搜索范围是否只有附件
  19. //搜索范围只选择附件,是否有附件条件无效;
  20. isFileSearch = in.SelectType == "filetext"
  21. wordsMusts, wordsShould, musts, mustNot []string
  22. findFields string
  23. selectTypeArr = strings.Split(in.SelectType, ",")
  24. isLogin = in.UserId != ""
  25. )
  26. if selectTypeArr == nil || len(selectTypeArr) == 0 {
  27. findFields = `"title"`
  28. } else {
  29. findFields = fmt.Sprintf(`"%s"`, strings.Join(selectTypeArr, "\",\""))
  30. }
  31. switchBool := strings.Contains(findFields, "detail") && strings.Contains(findFields, "title") && IC.C.SearchTypeSwitch
  32. if mustQuery != "" {
  33. musts = append(musts, mustQuery)
  34. }
  35. //采购单位
  36. if in.Buyer != "" {
  37. musts = append(musts, util.GetMatchArrSql("buyer.mbuyer", strings.Split(in.Buyer, ",")...))
  38. }
  39. //中标单位
  40. if in.Winner != "" {
  41. musts = append(musts, util.GetMatchArrSql("s_winner.mwinner", strings.Split(in.Winner, ",")...))
  42. }
  43. //代理机构
  44. if in.Agency != "" {
  45. musts = append(musts, util.GetMatchArrSql("agency.magency", strings.Split(in.Agency, ",")...))
  46. }
  47. //此时关键词中间有IC.C.JYKeyMark进行隔离
  48. if in.KeyWords != "" {
  49. var (
  50. keyWordsMusts []string
  51. )
  52. for _, v := range strings.Split(in.KeyWords, IC.C.JYKeyMark) {
  53. if elastic.ReplaceYH(v) == "" {
  54. continue
  55. }
  56. //单个字 搜索范围 有全文或者附件 无标题 例如:学 虚拟机 detail 搜索的时候加上标题
  57. //detail 正文不支持单字查询
  58. if len([]rune(elastic.ReplaceYH(v))) == 1 && DetailFileORTitle(findFields) {
  59. findFields += `,"title"`
  60. } else if switchBool && len([]rune(elastic.ReplaceYH(v))) > 1 {
  61. //标题 全文搜索 搜索类型开关打开 默认搜索全文;(全文包含标题)(单字排除)
  62. if strings.Contains(findFields, `"title",`) {
  63. findFields = strings.Replace(findFields, `"title",`, ``, -1)
  64. } else if strings.Contains(findFields, `,"title"`) {
  65. findFields = strings.Replace(findFields, `,"title"`, ``, -1)
  66. }
  67. }
  68. keyWordsMusts = append(keyWordsMusts, fmt.Sprintf(fmt.Sprintf(multiMatch, "%s", findFields), elastic.ReplaceYH(v)))
  69. }
  70. //搜索关键词模式;默认0:包含所有,1:包含任意
  71. if in.WordsMode == 1 {
  72. wordsShould = append(wordsShould, fmt.Sprintf(elastic.NgramMust, strings.Join(keyWordsMusts, ",")))
  73. } else {
  74. wordsMusts = append(wordsMusts, keyWordsMusts...)
  75. }
  76. }
  77. //附加词
  78. if in.AdditionalWords != "" {
  79. //多组附加词,每组间,号隔开。每组内如果关键词中间有空格,自动分词
  80. var (
  81. addWordsMusts []string
  82. )
  83. for _, aws := range strings.Split(in.AdditionalWords, ",") {
  84. var (
  85. addWordsMust []string
  86. )
  87. for _, v := range strings.Split(aws, IC.C.JYKeyMark) {
  88. if elastic.ReplaceYH(v) == "" {
  89. continue
  90. }
  91. //单个字 搜索范围 有全文或者附件 无标题 例如:学 虚拟机 detail 搜索的时候加上标题
  92. //detail 正文不支持单字查询
  93. if len([]rune(elastic.ReplaceYH(v))) == 1 && DetailFileORTitle(findFields) {
  94. findFields += `,"title"`
  95. } else if switchBool && len([]rune(elastic.ReplaceYH(v))) > 1 {
  96. //标题 全文搜索 搜索类型开关打开 默认搜索全文;(全文包含标题)(单字排除)
  97. if strings.Contains(findFields, `"title",`) {
  98. findFields = strings.Replace(findFields, `"title",`, ``, -1)
  99. } else if strings.Contains(findFields, `,"title"`) {
  100. findFields = strings.Replace(findFields, `,"title"`, ``, -1)
  101. }
  102. }
  103. addWordsMust = append(addWordsMust, fmt.Sprintf(fmt.Sprintf(multiMatch, "%s", findFields), elastic.ReplaceYH(v)))
  104. addWordsMusts = append(addWordsMusts, addWordsMust...)
  105. if in.WordsMode == 0 {
  106. wordsMusts = append(wordsMusts, addWordsMust...)
  107. }
  108. addWordsMust = []string{}
  109. }
  110. //搜索关键词模式;默认0:包含所有,1:包含任意
  111. if in.WordsMode == 1 {
  112. wordsShould = append(wordsShould, fmt.Sprintf(elastic.NgramMust, strings.Join(addWordsMusts, ",")))
  113. addWordsMusts = []string{}
  114. }
  115. }
  116. }
  117. //搜索关键词模式;默认0:包含所有,1:包含任意
  118. //包含任意一组
  119. if len(wordsShould) > 0 {
  120. musts = append(musts, fmt.Sprintf(queryBoolShould, strings.Join(wordsShould, ",")))
  121. } else if len(wordsMusts) > 0 {
  122. musts = append(musts, fmt.Sprintf(elastic.NgramMust, strings.Join(wordsMusts, ",")))
  123. }
  124. //排除词
  125. if notKey := strings.TrimSpace(in.ExclusionWords); notKey != "" {
  126. notKeyMultiMatch := fmt.Sprintf(multiMatch, "%s", findFields)
  127. var notKeyMustNot []string
  128. //多组排除词
  129. for _, nks := range strings.Split(notKey, ",") {
  130. //单组排除词 空格分割
  131. for _, v := range strings.Split(nks, IC.C.JYKeyMark) {
  132. v = strings.TrimSpace(v)
  133. if v == "" {
  134. continue
  135. }
  136. if len([]rune(elastic.ReplaceYH(v))) == 1 {
  137. //单个字 搜索范围 有全文或者附件 无标题 例如:学 虚拟机 detail 搜索的时候加上标题
  138. if DetailFileORTitle(findFields) {
  139. notKeyMultiMatch = fmt.Sprintf(multiMatch, "%s", findFields+`,"title"`)
  140. }
  141. }
  142. notKeyMustNot = append(notKeyMustNot, fmt.Sprintf(notKeyMultiMatch, elastic.ReplaceYH(v)))
  143. }
  144. }
  145. mustNot = append(mustNot, fmt.Sprintf(queryBoolShould, strings.Join(notKeyMustNot, ",")))
  146. }
  147. //行业
  148. if in.Industry != "" && isLogin {
  149. var (
  150. topSC []string
  151. topQT bool
  152. )
  153. for _, sv := range strings.Split(in.Industry, ",") {
  154. if strings.Contains(sv, "其他") {
  155. if len(strings.Split(sv, "_")) > 1 {
  156. topSC = append(topSC, strings.Split(sv, "_")[0])
  157. } else {
  158. topQT = true
  159. }
  160. }
  161. }
  162. //一级行业-其他
  163. if topQT {
  164. mustNot = append(mustNot, `{"exists": {"field": "s_topscopeclass"}}`)
  165. }
  166. if len(topSC) > 0 {
  167. //二级行业-其他
  168. musts = append(musts, fmt.Sprintf(queryBoolMustScopeClass, `"`+strings.ReplaceAll(in.Industry, ",", `","`)+`"`, `"`+strings.Join(topSC, `","`)+`"`))
  169. } else {
  170. musts = append(musts, fmt.Sprintf(queryBoolMustA, "s_subscopeclass", `"`+strings.ReplaceAll(in.Industry, ",", `","`)+`"`))
  171. }
  172. }
  173. //价格
  174. if in.Price != "" && len(strings.Split(in.Price, "-")) > 1 {
  175. minPrice, maxPrice := strings.Split(in.Price, "-")[0], strings.Split(in.Price, "-")[1]
  176. if minPrice != "" || maxPrice != "" {
  177. sq := ``
  178. if minPrice != "" {
  179. min, _ := strconv.ParseFloat(minPrice, 64)
  180. minPrice = fmt.Sprintf("%.0f", min*10000)
  181. if minPrice == "0" {
  182. minPrice = ""
  183. }
  184. }
  185. if maxPrice != "" {
  186. max, _ := strconv.ParseFloat(maxPrice, 64)
  187. maxPrice = fmt.Sprintf("%.0f", max*10000)
  188. if maxPrice == "0" {
  189. maxPrice = ""
  190. }
  191. }
  192. if minPrice != "" {
  193. sq += fmt.Sprintf(gte, minPrice)
  194. }
  195. if minPrice != "" && maxPrice != "" {
  196. sq += `,`
  197. }
  198. if maxPrice != "" {
  199. sq += fmt.Sprintf(lte, maxPrice)
  200. }
  201. if minPrice != "" || maxPrice != "" {
  202. query_price := fmt.Sprintf(queryBoolShould, fmt.Sprintf(queryBoolMustBoolShould, sq, sq))
  203. musts = append(musts, query_price)
  204. }
  205. }
  206. }
  207. //采购单位联系方式
  208. hasBuyerTel := in.BuyerTel
  209. if hasBuyerTel != "" {
  210. if hasBuyerTel == "y" {
  211. musts = append(musts, fmt.Sprintf(queryExists, "buyertel"))
  212. } else {
  213. mustNot = append(mustNot, fmt.Sprintf(queryExists, "buyertel"))
  214. }
  215. }
  216. //中标企业联系方式
  217. hasWinnerTel := in.WinnerTel
  218. if hasWinnerTel != "" {
  219. if hasWinnerTel == "y" {
  220. musts = append(musts, fmt.Sprintf(queryExists, "winnertel"))
  221. } else {
  222. mustNot = append(mustNot, fmt.Sprintf(queryExists, "winnertel"))
  223. }
  224. }
  225. //移动融创
  226. if in.MobileTag != nil && len(in.MobileTag) > 0 && in.IsPay { //仅付费bidding表有此字段
  227. musts = append(musts, fmt.Sprintf(queryBoolMustA, "mobile_tag", `"`+strings.Join(in.MobileTag, `","`)+`"`))
  228. }
  229. if isLogin { //需要登录
  230. //电脑端 物业专版BI
  231. if in.BidField == "BIProperty" {
  232. if !entity.MobileReg.MatchString(in.UserAgent) {
  233. musts = append(musts, fmt.Sprintf(queryBoolMustA, "tag_topinformation", `"情报_物业"`))
  234. //物业业态
  235. if in.PropertyForm != "" {
  236. arr := []string{}
  237. for _, v := range strings.Split(in.PropertyForm, ",") {
  238. arr = append(arr, fmt.Sprintf(`"%s"`, v))
  239. }
  240. musts = append(musts, fmt.Sprintf(queryBoolShould, fmt.Sprintf(`{"terms":{"tag_set.wuye.property_form":[%s]}}`, strings.Join(arr, ","))))
  241. }
  242. //业务类型
  243. if in.SubInformation != "" {
  244. arr := []string{}
  245. for _, v := range strings.Split(in.SubInformation, ",") {
  246. arr = append(arr, fmt.Sprintf(`"%s"`, v))
  247. }
  248. musts = append(musts, fmt.Sprintf(queryBoolShould, fmt.Sprintf(`{"terms":{"tag_subinformation":[%s]}}`, strings.Join(arr, ","))))
  249. }
  250. //价格区间
  251. if in.Scale != "" {
  252. arr := []string{}
  253. for _, v := range strings.Split(in.Scale, ",") {
  254. arr = append(arr, fmt.Sprintf(`"%s"`, v))
  255. }
  256. musts = append(musts, fmt.Sprintf(queryBoolShould, fmt.Sprintf(`{"terms":{"tag_set.wuye.scale":[%s]}}`, strings.Join(arr, ","))))
  257. }
  258. //合同周期
  259. if in.Period != "" {
  260. arr := []string{}
  261. for _, v := range strings.Split(in.Period, ",") {
  262. arr = append(arr, fmt.Sprintf(`"%s"`, v))
  263. }
  264. musts = append(musts, fmt.Sprintf(queryBoolShould, fmt.Sprintf(`{"terms":{"tag_set.wuye.period":[%s]}}`, strings.Join(arr, ","))))
  265. }
  266. //换手率
  267. if in.ChangeHand != 0 {
  268. if in.ChangeHand > 0 {
  269. //存在
  270. musts = append(musts, `{"range":{"tag_set.wuye.changehand":{"gt":0.3}}}`)
  271. }
  272. }
  273. if in.FileExists != "" {
  274. if in.FileExists == "1" {
  275. //存在
  276. musts = append(musts, fmt.Sprintf(queryBoolMustA, "tag_set.wuye.isfile", `"63"`))
  277. } else {
  278. //不存在
  279. mustNot = append(mustNot, fmt.Sprintf(queryExists, "tag_set.wuye.isfile"))
  280. }
  281. }
  282. }
  283. } else {
  284. //附件--非BI
  285. fileExists := in.FileExists
  286. if !isFileSearch && fileExists != "" {
  287. if fileExists == "1" { //有附件
  288. musts = append(musts, fmt.Sprintf(queryBoolMustTerm, true))
  289. } else if fileExists == "-1" { //无附件
  290. mustNot = append(mustNot, fmt.Sprintf(queryBoolMustTerm, true))
  291. }
  292. }
  293. if in.BidField == "medical" { // 如果是领域化数据则需要加标签
  294. musts = append(musts, fmt.Sprintf(queryBoolMustTermDomain, "0101"))
  295. }
  296. }
  297. }
  298. //in.BidField 剑鱼默认招标信息搜索 此参数为空**
  299. qstr = fmt.Sprintf(query, strings.Join(musts, ","), strings.Join(mustNot, ","))
  300. log.Println("qstr:", qstr)
  301. return
  302. }
  303. // GetBidSearchQuery 整理地区、城市、发布时间、信息类型、采购单位类型 查询条件
  304. func GetBidSearchQuery(in *bxcore.SearchReq) string {
  305. query := ``
  306. //省份
  307. area := in.Province
  308. isLogin := in.UserId != ""
  309. if area != "" {
  310. query += `{"terms":{"area":[`
  311. for k, v := range strings.Split(area, ",") {
  312. if k > 0 {
  313. query += `,`
  314. }
  315. query += `"` + v + `"`
  316. }
  317. query += `]}}`
  318. }
  319. //市--未登录用户不能根据市和地区筛选
  320. city := in.City
  321. if city != "" && isLogin {
  322. if len(query) > 0 {
  323. query += ","
  324. }
  325. query += `{"terms":{"city":[`
  326. for k, v := range strings.Split(city, ",") {
  327. if k > 0 {
  328. query += `,`
  329. }
  330. query += `"` + v + `"`
  331. }
  332. query += `]}}`
  333. }
  334. district := in.District
  335. if district != "" && isLogin {
  336. if len(query) > 0 {
  337. query += ","
  338. }
  339. for k, v := range strings.Split(district, ",") {
  340. if k > 0 {
  341. query += `,`
  342. }
  343. cityName := strings.Split(v, "_")[0]
  344. districtName := strings.Split(v, "_")[1]
  345. queryBoolMustAndDistrict := `{"bool":{"must":[{"terms":{"city":["%s"]}},{"terms":{"district":["%s"]}}]}}`
  346. query += fmt.Sprintf(queryBoolMustAndDistrict, cityName, districtName)
  347. }
  348. }
  349. if query != "" {
  350. query = fmt.Sprintf(queryBoolShould, query)
  351. }
  352. //发布时间
  353. publishTime := in.PublishTime
  354. if publishTime != "" {
  355. startTime, endTime := "", ""
  356. now := time.Now()
  357. switch publishTime {
  358. case "lately-7":
  359. startTime = fmt.Sprint(time.Date(now.Year(), now.Month(), now.Day()-7, 0, 0, 0, 0, time.Local).Unix())
  360. case "lately-30":
  361. startTime = fmt.Sprint(time.Date(now.Year(), now.Month(), now.Day()-30, 0, 0, 0, 0, time.Local).Unix())
  362. case "thisyear":
  363. startTime = fmt.Sprint(time.Date(now.Year()-1, now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second(), 0, time.Local).Unix())
  364. endTime = fmt.Sprint(now.Unix())
  365. case "threeyear":
  366. startTime = fmt.Sprint(time.Date(now.Year()-3, now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second(), 0, time.Local).Unix())
  367. endTime = fmt.Sprint(now.Unix())
  368. case "fiveyear":
  369. startTime = fmt.Sprint(time.Date(now.Year()-5, now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second(), 0, time.Local).Unix())
  370. endTime = fmt.Sprint(now.Unix())
  371. default:
  372. if len(strings.Split(publishTime, "-")) > 1 {
  373. startTime = strings.Split(publishTime, "-")[0]
  374. endTime = strings.Split(publishTime, "-")[1]
  375. //电脑端 时间选择 开始时间当天和结束时间当天相同
  376. if startTime == endTime {
  377. et, _ := strconv.ParseInt(endTime, 0, 64)
  378. etTime := time.Unix(et, 0)
  379. endTime = fmt.Sprint(time.Date(etTime.Year(), etTime.Month(), etTime.Day()+1, 0, 0, 0, 0, time.Local).Unix())
  380. }
  381. }
  382. }
  383. if startTime != "" || endTime != "" {
  384. if len(query) > 0 {
  385. query += ","
  386. }
  387. query += `{"range":{"publishtime":{`
  388. if startTime != "" {
  389. query += `"gte":` + startTime
  390. }
  391. if startTime != "" && endTime != "" {
  392. query += `,`
  393. }
  394. if endTime != "" {
  395. query += `"lt":` + endTime
  396. }
  397. query += `}}}`
  398. }
  399. }
  400. //信息类型-二级
  401. subtype := in.Subtype
  402. topType := MC.If(in.TopType != "", strings.Split(in.TopType, ","), []string{}).([]string)
  403. allType := ``
  404. //二级分类
  405. if subtype != "" {
  406. var typeInt = 0
  407. allType += `{"terms":{"subtype":[`
  408. for k, v := range strings.Split(subtype, ",") {
  409. if tType := MC.If(topTypeMap[v] != "" && in.TopType == "", topTypeMap[v], "").(string); tType != "" {
  410. topType = append(topType, tType)
  411. typeInt += 1
  412. continue
  413. }
  414. if k > typeInt {
  415. allType += `,`
  416. }
  417. allType += `"` + v + `"`
  418. }
  419. allType += `]}}`
  420. if typeInt == len(strings.Split(subtype, ",")) {
  421. allType = ``
  422. }
  423. }
  424. //信息类型 一级分类
  425. log.Println("topType:", topType)
  426. if len(topType) > 0 {
  427. if allType != "" {
  428. allType += ","
  429. }
  430. allType += `{"terms":{"toptype":[`
  431. for k, v := range topType {
  432. if k > 0 {
  433. allType += `,`
  434. }
  435. allType += `"` + v + `"`
  436. }
  437. allType += `]}}`
  438. }
  439. if allType != "" {
  440. if query != "" {
  441. query += ","
  442. }
  443. query += fmt.Sprintf(queryBoolShould, allType)
  444. }
  445. //采购单位类型
  446. buyerClass := in.BuyerClass
  447. if buyerClass != "" {
  448. if len(query) > 0 {
  449. query += ","
  450. }
  451. query += `{"terms":{"buyerclass":[`
  452. for k, v := range strings.Split(buyerClass, ",") {
  453. if k > 0 {
  454. query += `,`
  455. }
  456. query += `"` + v + `"`
  457. }
  458. query += `]}}`
  459. }
  460. //电脑端 物业专版BI
  461. if !entity.MobileReg.MatchString(in.UserAgent) {
  462. if in.ExpireTime != "" {
  463. if len(query) > 0 {
  464. query += ","
  465. }
  466. startTime, endTime := "", ""
  467. now := time.Now()
  468. if in.ExpireTime == "1" { //本月到期
  469. startTime = fmt.Sprint(now.Unix())
  470. first := time.Date(now.Year(), now.Month()+1, 1, 0, 0, 0, 0, time.Local)
  471. endTime = fmt.Sprint(first.AddDate(0, 0, 0).Unix())
  472. /* endTime = fmt.Sprint(time.Date(now.Year(), now.Month()+1, 1, 0, 0, 0, 0, time.Local).Unix())*/
  473. } else if in.ExpireTime == "1-3" { //1-3个月到期
  474. startTime = fmt.Sprint(time.Date(now.Year(), now.Month()+1, now.Day(), 0, 0, 0, 0, time.Local).Unix())
  475. endTime = fmt.Sprint(time.Date(now.Year(), now.Month()+3, now.Day(), 0, 0, 0, 0, time.Local).Unix())
  476. } else if in.ExpireTime == "3-6" { //3-6个月到期
  477. startTime = fmt.Sprint(time.Date(now.Year(), now.Month()+3, now.Day(), 0, 0, 0, 0, time.Local).Unix())
  478. endTime = fmt.Sprint(time.Date(now.Year(), now.Month()+6, now.Day(), 0, 0, 0, 0, time.Local).Unix())
  479. } else if in.ExpireTime == "6-12" { //6-12个月到期
  480. startTime = fmt.Sprint(time.Date(now.Year(), now.Month()+6, now.Day(), 0, 0, 0, 0, time.Local).Unix())
  481. endTime = fmt.Sprint(time.Date(now.Year(), now.Month()+12, now.Day(), 0, 0, 0, 0, time.Local).Unix())
  482. } else if in.ExpireTime == "12" { //12个月以后
  483. startTime = fmt.Sprint(time.Date(now.Year(), now.Month()+12, now.Day(), 0, 0, 0, 0, time.Local).Unix())
  484. } else if len(strings.Split(in.ExpireTime, "_")) > 1 {
  485. startTime = strings.Split(in.ExpireTime, "_")[0]
  486. endTime = strings.Split(in.ExpireTime, "_")[1]
  487. etTime := time.Now()
  488. if endTime != "" {
  489. et, _ := strconv.ParseInt(endTime, 0, 64)
  490. etTime = time.Unix(et, 0)
  491. }
  492. endTime = fmt.Sprint(time.Date(etTime.Year(), etTime.Month(), etTime.Day()+1, 0, 0, 0, 0, time.Local).Unix())
  493. }
  494. query += `{"range":{"expiredate":{`
  495. if startTime != "" {
  496. query += `"gte":` + startTime
  497. }
  498. if startTime != "" && endTime != "" {
  499. query += `,`
  500. }
  501. if endTime != "" {
  502. query += `"lt":` + endTime
  503. }
  504. query += `}}}`
  505. }
  506. }
  507. return query
  508. }
  509. // DetailFileORTitle 包含正文或 附件 不包含标题
  510. func DetailFileORTitle(findFields string) bool {
  511. return (strings.Contains(findFields, `"detail"`) || strings.Contains(findFields, `"filetext"`)) && !strings.Contains(findFields, `"title"`)
  512. }