2013-08-23 42 views
2

我是使用cfcollection和cfsearch的新手,但我放棄了它,它似乎工作。然後,我清理了收藏品,並停止了工作。然後,我決定刪除集合並重新開始。集合已被刪除,但現在相同的代碼不會返回任何結果。ColdFusion收集/搜索將不會填充

我的查詢返回5個結果,即收集和後續搜索應該正在拾取,但返回的搜索爲空,即使在我的條件中指定了通配符*。

我的代碼下面有什麼問題嗎?沒有錯誤或任何事情,只是空白的結果。

public void function ajax() { 

    param name="params.keywords" default="SoundCloud"; 

    onlyProvides("json"); 

    local.collectionPath = expandPath("./") & "collections/"; 

    // Delete 
    /* 
    collection 
     action="delete" 
     collection="pincollection" 
     path="#local.collectionPath#"; 
    */ 

    collection 
     action="list" 
     name="local.collectionList"; 

    local.collectionList = valueList(collectionList.name); 

    if (! listFind(local.collectionList, "pincollection")) { 

     collection 
      action="create" 
      collection="pincollection" 
      engine="solr" 
      categories="yes" 
      path="#local.collectionPath#"; 

    } 

    local.pins = model("pin").findAll(

     include  = "user", 
     order  = "createdat DESC" 

    ); 

    index 
     collection="pincollection" 
     action="update" 
     type="custom" 
     title="title" 
     body="description" 
     custom1="latitude" 
     custom2="longitude" 
     custom3="typeid" 
     custom4="createdAt" 
     custom5="updatedAt" 
     query="local.pins" 
     category="typeid" 
     key="id"; 

    search 
     name="local.pinSearch" 
     collection="pincollection" 
     contextHighlightBegin="<strong>" 
     contextHighlightEnd="</strong>" 
     category="2,1" 
     maxrows="100" 
     criteria="•"; 


    writeDump(var=local.pinSearch); // Empty search query. 
    writeDump(var=local.pins, abort=true); // Original query returns 5 results. 

    renderWith(data=local.pinSearch, layout=false); 

} 

我正在使用Railo。

我可以看到,在我的集合文件夾中,我的集合的文件夾已創建,但不包含任何文件。

我是使用ColdFusion/Railo進行搜索的新手。它看起來很直接,但我很難過。

謝謝, Mikey。

PS - 我使用CFWheels,因此使用了一些CFWheels的特定功能。這些可以被忽略。

+0

不回答你的問題,但你不應該被索引,你想要做一個搜索每次數據。索引應該作爲一個單獨的過程完成 - 通常是當您從數據庫添加/更新/刪除項目或從系統添加/更新/刪除文檔時。您的收藏應該一次性創建,如果需要,您應該有一個單獨的過程來重建它。 –

+0

@ScottStroz謝謝。那麼,我應該把它放在當前「創建」的狀態嗎?所以,如果它不存在,我們創建並填充它,否則就像正常一樣搜索?聽起來合乎邏輯。我都是新來的。但仍然沒有顯示結果。 –

+0

是的,你可以做到這一點。當我使用搜索集合時,我確保任何插入/更新/刪除操作也會更新集合。另外,我有一個清理集合和重新索引的進程 - 這裏是我要檢查集合是否存在的位置,如果沒有,創建它,然後索引。 –

回答

0

在對此進行故障排除之前,請考慮切換到專用的Solr服務器(如果可以)。在9年前我們很快就達到了Solr的極限,並且使用Shannon Hicks的CFSolrLib項目連接到Tomcat上新安裝的Solr。其中一些好處是:

  • 減少CF服務器的開銷。
  • 索引性能提升。
  • 從您的應用程序的其餘部分中分離與搜索相關的疑難解答(如您的情況)。
  • 您可以自由更改/升級您的Solr服務器。

香農在github項目:https://github.com/iotashan/cfsolrlib

MC