2014-09-22 290 views
0

我對Solr完全陌生,而且我試圖創建一個查詢,它將返回所有包含'成分中的一個或多個值的文檔'字段(製表符分隔的字符串),但排除那些在同一字段上具有其他值的字段。我們正在運行的Solr 4.9Solr查詢'in'和'not in'爲相同的字段

這裏的模式:

<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" 

我得到的結果,土豆或啤酒的成分領域。任何想法?我錯過了什麼?

謝謝!

+0

嘗試:'標題:比薩餅和成分:(「橄欖油」,而不是(啤酒或馬鈴薯))' – arun 2014-09-22 20:26:08

+0

剛剛試了一下,不行的,但感謝的努力。這可能與我不知道的某種類型的緩存有關嗎? – xburgos 2014-09-22 22:16:20

+0

什麼樣的領域是'成分'?你可以發佈你的模式? – arun 2014-09-23 02:05:35

回答

0

我想出了這一個,我只需要在我的搜索條件前加/後綴*。

title:pizza AND ingredient:"olive oil" AND -ingredient:(*beer* *potatoes*)