How can I use Verity to index and search database content in ColdFusion 9?

后端 未结 1 1576
感情败类
感情败类 2021-02-09 04:30

I have tried to use ColdFusion 9 to build search engine in my site. The key is Verity which I read it is the best tool to do the indexing and searching in my database content.

1条回答
  •  我寻月下人不归
    2021-02-09 05:05

    Actually, you have two great engines for CF9: Verity (classic) and Solr (modern).

    Both of them implement the idea of collections. Creating and maintanence of the collection is pretty obvious and can be found in manual (see previous links).

    The main hint for you can be found on cfindex tag manual page: you can populate (update) the collection with query data. Set type custom, enter the query name and all columns you need (combinations may vary).

    All you need after that is to use cfsearch.

    Also I can recommend to set up the script executed by scheduler to refresh your collection periodically.

    EDIT

    Sample code (note: code not tested, just the simplified cut from my old component). These are two methods of the CFC.

    
        
        
        
    
    
            
            
                SELECT C.id, C.title, C.content, P.name AS page
                FROM #variables.tableContent# C
                INNER JOIN #variables.tablePages# P
                    ON C.id_page = P.id
            
    
    
            
            
    
            
    
            
    
            
    
        
            
            
        
        
    
    
    
    
    
        
        
        
        
        
        
        
    
            
            
    
    
            
    
            
            
            
                local.res = StructNew();
                local.res["id"] = local.searchResults.key;
                local.res["summary"] = Left(local.searchResults.summary, 500) & "...";
                // highlight the search phrase
                local.res["summary"] = ReplaceNoCase(local.res["summary"], arguments.criteria,  "" & arguments.criteria & "", "ALL");
                local.res["page"] = local.searchResults.custom1;
                local.res["title"] = local.searchResults.title;
                ArrayAppend(local.resultsArray, local.res);
            
            
    
            
    
        
            
            
        
        
    
    

    0 讨论(0)
提交回复
热议问题