[英]Solr Query with 'in' and 'not in' for the same field
我對Solr完全陌生,我正在嘗試創建一個查詢,該查詢將返回“成分”字段(制表符分隔的字符串)中具有一個或多個值的所有文檔,但排除那些具有其他值的文檔。同一領域。 我們正在運行Solr 4.9
這里的架構:
<fields>
<field name="_version_" type="long" indexed="true" stored="true" multiValued="false"/>
<field name="uri" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="title" type="text_general" indexed="true" stored="true" multiValued="false" />
<field name="text" type="text_general" indexed="true" stored="true" multiValued="false" />
<field name="ingredient" type="tab-delimited-string" indexed="true" stored="true" multiValued="false" />
這是一個文檔樣本:
{
"text": "Preheat oven to 350 degrees F.\n\nPlace potatoes, heavy cream, egg, salt, parmesan and marjoram in a blender container.\n\nCover and blend at high speed for about 30 seconds.\n\nFill dough in a greased baking dish and bake uncovered for 25-30 minutes at 350 F.\n\nPlace remaining ingredients (without the mozzarella) in a blender, cover and blend at high speed for about 10 seconds.\n\nSpread sauce on potato dough, cover with mozzarella and some sprinkles of oil and bake again uncovered for 20-25 minutes at 350 F.",
"ingredient": "1/2 cup parmesan cheese, grind\t1 lb potato, uncooked,skin removed,diced\t1/2 cup heavy cream\t1 egg\t1 teaspoon salt\t1/2 teaspoon marjoram\t2 cloves garlic, chopped\t1 1/3 cups Tomatoes, diced\tsalt\tpepper\tbasil\t1 cup mozzarella cheese, finely grated\tolive oil",
"uri": "http://www.food.com/recipe/potato-pizza-58181",
"title": "Potato Pizza",
"_version_": 1477518762807656400
},
搜索並閱讀了一些手冊后,我提出了以下建議:
title:pizza AND ingredient:"olive oil" AND -ingredient:("beer" "potatoes")
但這不起作用。 我也嘗試了下面的東西,但也沒有用
title:pizza AND ingredient:"olive oil" AND -ingredient:"beer " "potatoes"
title:pizza AND ingredient:"olive oil" AND -ingredient:"beer" AND -ingredient:"potatoes"
我得到的結果是在配料字段中有土豆或啤酒。 有什么想法嗎,我想念什么嗎?
謝謝!。
我想出了這個,我只需要在搜索詞前加/ *。
title:pizza AND ingredient:"olive oil" AND -ingredient:(*beer* *potatoes*)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.