2016-06-20 29 views
0

我有在冠軍描述作者EANISBN searchs查詢。彈性得到相關的搜索結果

我提升爲冠軍^ 3筆者^ 2EAN^100ISBN^100

當我用ean命中時,它只返回1個結果。 (ean是一個數字)

ISBN是一個字符串例如。 978-12-1234-123-8我得到了成千上萬的ISBN結果。但是如果碰到了,那麼結果就會稍微高一些。

我正在使用multi_match帶有類型best_fields

有沒有辦法只得到相關結果?或者我必須自己做?

編輯:

映射:

"product": { 
"properties": { 
    "img": { 
    "type": "string" 
    }, 
    "dobrovsky_rating": { 
    "type": "float" 
    }, 
    "isbn": { 
    "type": "string" 
    }, 
    "saleType": { 
    "type": "string" 
    }, 
    "rating": { 
    "type": "float" 
    }, 
    "description": { 
    "analyzer": "hunspell_cs", 
    "type": "string" 
    }, 
    "availability": { 
    "type": "string" 
    }, 
    "priceDph": { 
    "type": "long" 
    }, 
    "title": { 
    "analyzer": "hunspell_cs", 
    "type": "string" 
    }, 
    "url": { 
    "index": "not_analyzed", 
    "type": "string" 
    }, 
    "rating_count": { 
    "type": "long" 
    }, 
    "ean": { 
    "type": "string" 
    }, 
    "serie": { 
    "analyzer": "hunspell_cs", 
    "type": "string" 
    }, 
    "id": { 
    "type": "long" 
    }, 
    "category": { 
    "analyzer": "hunspell_cs", 
    "type": "string" 
    }, 
    "authors": { 
    "analyzer": "hunspell_cs", 
    "type": "string" 
    } 
} 

數據例如:

Id: 123 
Title: Game of Thrones 
Author: George R.R. Martin 
Img: www.aaa.cz/got.png 
Url: www.aaa.cz/got.html 
Description: Game of Thrones is a ... 
EAN: 9788071974925 
ISBN: 978-80-7197-492-5 
... 

回答

1

試試這個

POST /MyINdex/_search 
{ 
    "from": 0, 
    "size": 10, 
    "_source": { 
    "include": [ 
     "*" 
    ] 
    }, 
    "query": { 
    "query_string": { 
     "query": "978-12-1234-123-8", 
     "fields": [ 
     "title^3", 
     "author2^2", 
     "ean^100", 
     "isbn^100", 
     "description^1" 
     ], 
     "default_operator": "and" 
    } 
    } 
} 
+0

它適用於ISBN。但作者,標題和說明無法正常工作。 – tttpapi

+0

你可以發佈你的映射和文件的例子嗎? –

+0

我編輯了我的問題。 – tttpapi

相關問題