Commit ac67a6be by 孙龙

up

parent c3ef9a6d
......@@ -93,6 +93,20 @@ Index=liexin_ziying
16=g4
17=x4
;自营以某些单位进行搜索时,进行特殊处理
[ZIYING_MEASURE]
0=
1=uf
2=v
3=kg
4=MHz
5=pf
6=pin
7=ppm
8=kw
[official_website]
1 = https://www.futureelectronics.cn/search/?text=liexin
2 = http://www.powerandsignal.com/Products/Search?searchBox=liexin
......
......@@ -149,3 +149,10 @@ func Rand(min, max int) int {
return int(n.Int64()) + min
}
func CopyMapString(distmap map[string]string) map[string]string{
tmpmap := make(map[string]string,0)
for k, v := range distmap {
tmpmap[k] = v
}
return tmpmap
}
\ No newline at end of file
......@@ -10,6 +10,7 @@ import (
"gopkg.in/olivere/elastic.v5"
"regexp"
"search_server/model"
"search_server/pkg/common"
"search_server/pkg/config"
"search_server/pkg/gredis"
"strconv"
......@@ -95,7 +96,7 @@ func zy(req map[string]string,_type byte,isCheck byte) (rsp *model.ZyhResponse){
if err != nil{
logger.Error("解析自营分类列表失败 s%,%s",err,classList)
}
//fmt.Println(classList)
classidstr := req["class_id/condition"]
classid,err = strconv.ParseInt(classidstr, 10, 64)
if err != nil{
......@@ -107,20 +108,23 @@ func zy(req map[string]string,_type byte,isCheck byte) (rsp *model.ZyhResponse){
if classid > 0 && item.ClassID1 == classid{
item.Flag = 1
classLight = append(classLight,item)
req["class_id1/condition"] = strconv.FormatInt(item.ClassID1,10)
break OuterLoop
}
for _,item2 := range item.ClassID2List{
if classid > 0 && item2.ClassID2 == classid{
item2.Flag = 1
req["class_id2/condition"] = strconv.FormatInt(item2.ClassID2,10)
classLight = append(classLight,item)
break OuterLoop
}
}
}
}
searchZiYingGoods(req,true,zhyClassList,classLight,_type)
req2 := make(map[string]string,0)
req2 = common.CopyMapString(req)
delete(req2,"class_id/condition")
searchZiYingGoods(req2,true,zhyClassList,classLight,_type)
return nil
}
......@@ -145,21 +149,17 @@ func searchZiYingGoods( req map[string]string,zy bool,classList *model.ZhyClassL
ziyingBrandReplace := config.Cfg.Section("ZIYING_BRAND_REPLACE").KeysHash()
if ziyingBrandReplace != nil && ziyingBrandReplace[goodsNameCondition] != "" {
goods_name_arr = append(goods_name_arr,map[string]string{"brand_name/condition":ziyingBrandReplace[goodsNameCondition]})
delete(req,"goods_name/condition")
}
}
if req["p"] == "" || req["p"] == "0"{
req["p"] = "1"
}
//index := config.Get("ZIYING_CONFIG")
goods_temp_status := 0
source := elastic.NewSearchSource()
source.StoredFields("goods_id","goods_name","sample_max_number","sample_status","sample_class_id")
query := elastic.NewBoolQuery()
if(len(req) > 0){
for k,v:=range req{
......@@ -204,15 +204,13 @@ func makeQuery(query *elastic.BoolQuery,conditions []string,goods_temp_status *i
switch searchCondition{
case "condition":
//status
if searchKey == "status"{
*goods_temp_status = 1
}
if searchKey != "status" && searchCondition == ""{
return false;
}
//goods_name
if searchKey == "goods_name"{
switch searchKey {
case "status":
*goods_temp_status = 1
case "goods_name":
//fmt.Println(5569)
strNo := []string{"/" , "," ,"、" ,"?" , "," , ":",",","?",",","、",":"}
for _,strNoV:=range strNo{
......@@ -279,21 +277,17 @@ func makeQuery(query *elastic.BoolQuery,conditions []string,goods_temp_status *i
goods_name_arr := append(term_v,goods_name_cn...)
fmt.Println("goods_name_arr",goods_name_arr)
*keyword = *searchValue
fmt.Println("goods_name",term_v)
for _,v:=range term_v{
if v != ""{
query.Must(elastic.NewTermQuery("goods_name",v))
}
}
if len(goods_name_arr) > 0{
query.Must(elastic.NewMatchQuery("goods_name_cn",strings.Join(goods_name_cn," ")).MinimumShouldMatch("100%"))
}
}else{
case "brand_name":
term_v = strings.Split(*searchValue,",")
}
//fmt.Println(term_v)
*searchValue = strings.ToUpper(strings.TrimSpace(*searchValue))
if searchKey == "brand_name"{
reg := regexp.MustCompile(`[[:^alnum:]]+`)
if len(term_v) > 0{
for k,v:=range term_v{
......@@ -301,16 +295,33 @@ func makeQuery(query *elastic.BoolQuery,conditions []string,goods_temp_status *i
}
query.Must(elastic.NewTermsQuery("auto_brand_name2",term_v))
}
}
//stock
if searchKey == "stock"{
case "stock":
if stockValue,err = strconv.ParseInt(*searchValue, 10, 64);err == nil{
if stockValue > 1000000 {
stockValue = 1000000
}
query.Must(elastic.NewRangeQuery("stock").Gte(stockValue))
}
default:
*searchValue = strings.ToUpper(strings.TrimSpace(*searchValue))
term_v = strings.Split(*searchValue,",")
term_v_interface := make([]interface{},0)
for _,v:=range term_v{
term_v_interface = append(term_v_interface,v)
}
for _,field:=range int_field{
if searchKey == field{
for k,v:=range term_v{
if stockValue,err = strconv.ParseInt(v, 10, 64);err == nil{
term_v_interface[k] = stockValue
}
}
break
}
}
query.Must(elastic.NewTermsQuery(searchKey,term_v_interface))
}
case "order":
case "range":
case "sr":
......
package main
import (
<<<<<<< HEAD
"bytes"
"fmt"
"strconv"
)
func intsToString(values []int) string {
......@@ -19,30 +19,23 @@ func intsToString(values []int) string {
return buf.String()
}
func main() {
fmt.Println(intsToString([]int{1, 2, 3})) // "[1, 2, 3]"
=======
"fmt"
"strconv"
)
func main() {
var a,b,c float64
a=1.69*100
b=1.7*10
c=a*b/(100*10)
//ȷ2.873
//��ȷ���2.873
fmt.Println(c)
//fmt.Println(fmt.Sprintf("%.2f",c))
//fmt.Println(FloatRound(c,2))
}
// ȡСλ
// ��ȡС��λ��
func FloatRound(f float64, n int) float64 {
format := "%." + strconv.Itoa(n) + "f"
//fmt.Println(format)
res, _ := strconv.ParseFloat(fmt.Sprintf(format, f), 64)
return res
>>>>>>> 326ae7ed67d5d2db331dddd1277d36b8b1992b08
}
\ No newline at end of file
package main
import (
"log"
"os"
)
func breadthFirst(f func(item string) []string, worklist []string) {
seen := make(map[string]bool)
for len(worklist) > 0 {
items := worklist
worklist = nil
for _, item := range items {
if !seen[item] {
seen[item] = true
worklist = append(worklist, f(item)...)
}
}
}
}
func crawl(url string) []string {
fmt.Println(url)
list, err := links.Extract(url)
if err != nil {
log.Print(err)
}
return list
}
func main() {
// Crawl the web breadth-first,
// starting from the command-line arguments.
breadthFirst(crawl, os.Args[1:])
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment