Solved

Verity and K2 document manager

Posted on 2004-10-06
14
412 Views
Last Modified: 2013-12-20
I have created a document management system and now am at the point where I need to create a search feature that will search the content of each document.  I've begun to read up on Verity that is shipped with ColdFusion MX and also noticed the option of K2.  

Should I be using Verity or should I be looking into K2?  I created a collection in the ColdFusion administrator but I read that it is better to use the utilities instead of having ColdFusion create the collection.  Is that true and if so to how would I use these utilties?  

Has anyone set up a similar search function?  I need to make sure I am following the correct steps and I really need to get this working quickly so any help in what steps are necessary would be great.  Any documentation links would be great too.  

Does anyone have any code examples of searching a collection and outputting the results?  I need to somehow check each document compare it to my database record and then make sure the person searching has permission to view the document.  I actually have permissions set up on a folder level so is there a way to only allow folders that the person making the search has permission to?  Thanks for any help on this one!
0
Comment
Question by:Ike23
  • 7
  • 5
  • 2
14 Comments
 
LVL 9

Accepted Solution

by:
CFDevHead earned 300 total points
Comment Utility
I perfer Verity because it is quick and easy and it comes with CF
hre is some sample code

create you index
<CFSET IndexCollection = "Intranet">
<CFSET IndexDirectory = "D:\inetpub\wwwroot\Intranet\files">
<CFSET IndexRecurse = "YES">
<CFSET IndexExtensions = ".htm, .html, .txt, .doc, .xls, .pdf, .dot">
<CFSET IndexLanguage = "english">

<CFOUTPUT>

<CFINDEX
      collection="#IndexCollection#"
    action="UPDATE"
    type="PATH"
    key="#IndexDirectory#\"
    extensions="#IndexExtensions#"
    recurse="#IndexRecurse#"
    language="#IndexLanguage#"
      urlPath="http://intranet.somesite.com/"
>
</CFOUTPUT>
<HTML><HEAD>
    <TITLE>Search - Indexing Finished</TITLE>
</HEAD><BODY bgcolor="ffffff">

<FONT size="+1">Search</FONT> <BR>
<FONT size="+2"><B>Indexing Finished</B></FONT>


create your search form

<!--- template settings --->
<CFSET SearchDirectory = "D:\inetpub\wwwroot\Intranet">

<FONT FACE="Verdana, Arial" SIZE="+1">Welcome to Search</FONT> <BR>
<FONT FACE="Verdana, Arial" SIZE="+2"><B>Intranet Search</B></FONT>

<!--- search form definition --->
<FORM action="Search.cfm" method="post">
<INPUT TYPE="hidden" NAME="Criteria_Required" VALUE="Please enter some valid search criteria.">
<INPUT type="hidden" name="StartRow" value="1">

<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR>
<TD><FONT FACE="Verdana">Search For:</TD>
<TD><INPUT type="text" name="Criteria" size="50"></TD>
</TR>

<TR>
<TD><FONT FACE="Verdana">Max Results:</TD>
<TD><SELECT name="MaxRows"> <OPTION> 10 <OPTION SELECTED> 25 <OPTION> 100 </SELECT> &nbsp; &nbsp;
<INPUT type="submit" value="   Search   "></TD>
</TR>

<TR>
<TD COLSPAN="2">
<CFIF IsDefined("help")>
      <CFIF #Help# Is "Yes">
      <P><BR><CFINCLUDE TEMPLATE="vsearchelp.cfm">
      <CFELSE>
      <A HREF="vsearch.cfm?help=yes"><FONT FACE="Verdana, Arial" SIZE="-2" COLOR="red">Search Help</FONT></A>
      </CFIF>
<CFELSE>
<A HREF="search.cfm?help=yes"><FONT FACE="Verdana, Arial" SIZE="-2" COLOR="red">Search Help</FONT></A>
</CFIF>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;

</TD></TR>
</TABLE>
</FORM>


then display your search results

<!--- template settings --->
<CFSET SearchDirectory = "D:\inetpub\wwwroot\Intranet">
<CFSET SearchCollection = "Intranet">
<CFSET UseURLPath = "YES">
<CFPARAM NAME="Score" DEFAULT="1">
<CFPARAM NAME="Form.Criteria" DEFAULT=".">

<!--- retrieve requested files --->
<CFSEARCH
      name = "GetResults"
      collection = "#SearchCollection#"
      criteria = "#LCASE(Form.Criteria)#"
      maxRows = "#Evaluate(Form.MaxRows + 1)#"
      startRow = "#Form.StartRow#"
      TYPE="Simple"
>

<CFQUERY NAME=subSearch DBTYPE=Query>
SELECT DISTINCT * FROM GetResults ORDER BY Score DESC
</CFQUERY>
<HR WIDTH="500" ALIGN="left">
<FONT size="+1">search</FONT> <BR>
<FONT size="+2"><B>Search Results:</B> <FONT FACE="Verdana" SIZE="-2">Found <CFOUTPUT>#GetResults.RecordCount# out of #GetResults.RecordsSearched# </CFOUTPUT>files searched.</FONT></FONT>
<P>

<!--- no files found for specified criteria? --->
<CFIF GetResults.RecordCount is 0>
      <B>No files found for specified criteria</B>

<!--- ... else at least one file found --->
<CFELSE>

      <TABLE BORDER="0" cellspacing="0" cellpadding="2" WIDTH="500">

      <!--- table header --->
      <TR bgcolor="cccccc">
            <TD><B>#</B></TD>
            <TD><B>Score</B></TD>
            <TD><B>File</B></TD>
            <TD><B>Title</B></TD>
      </TR>

      <CFOUTPUT query="SubSearch" maxRows="#Form.MaxRows#">
                  
      <TR bgcolor="#IIf(CurrentRow Mod 2, DE('ffffff'), DE('eeeeee'))#">

            <!--- current row information --->
            <TD><FONT FACE="Verdana, Arial" SIZE="-2">#Evaluate(Form.StartRow + CurrentRow - 1)#</TD>

            <!--- score ---><CFSET ShowScore= (#Score#*100)>
            <TD><FONT FACE="Verdana, Arial" SIZE="-2">#ShowScore#%&nbsp;</TD>

            <!--- file name with the link returning the file --->
            <TD>
                  <CFIF UseURLPath>      <!--- URL parameter from cfsearch contains URL path info --->
                        <CFSET href = Replace(URL, " ", "%20", "ALL")>
                  <CFELSE>                  <!--- ... else use OpenFile to return the file --->
                        <CFSET href = "MyApplication_VOpenFile.cfm?serverFilePath=#URLEncodedFormat(Key)#">
                  </CFIF>
                  <A href="#href#"><FONT FACE="Verdana, Arial" SIZE="-2">#GetFileFromPath(Key)#</A>
            </TD>

            <!--- title for HTML files --->
            <TD><FONT FACE="Verdana, Arial" SIZE="-2"><CFIF #Left(Title,1)# Is "ç">&nbsp;<CFELSE>#Title#&nbsp;</CFIF></TD>

      </TR><CFSET NewSummary=#ReplaceNoCase(#Summary#, "#Criteria#", "<FONT CLASS=hl><B>#Criteria#</B></FONT>", "ALL")#>
      <TR bgcolor="#IIf(CurrentRow Mod 2, DE('ffffff'), DE('eeeeee'))#">
      <TD COLSPAN="4"><FONT FACE="Verdana, Arial" SIZE="-2">#Mid(NewSummary,1,250)#</FONT></TD>
      </TR>
      
      </CFOUTPUT>

      </TABLE>


      <!--- CFSEARCH tried to retrieve one more file than the number specified in the
            Form.MaxRows parameter. If number of retrieved files is greater than MaxRows
            we know that there is at least one file left. The following form contains only
            one button which reloads this template with the new StartRow parameter. --->

      <CFIF GetResults.RecordCount gt Form.MaxRows>
            <FORM action="search.cfm" method="post">
            <CFOUTPUT>
                  <INPUT type="hidden" name="Criteria" value="#Replace(Form.Criteria, """", "'", "ALL")#">
                  <INPUT type="hidden" name="MaxRows" value="#Form.MaxRows#">
                  <INPUT type="hidden" name="StartRow" value="#Evaluate(Form.StartRow + Form.MaxRows)#">
                  <INPUT type="submit" value="    More ...   ">
            </CFOUTPUT>
            </FORM>
      </CFIF>

</CFIF>

</BODY></HTML>


hope this helps and good luck

<P>


0
 
LVL 35

Expert Comment

by:mrichmon
Comment Utility
This may help:
Compare Verity Search Modes : http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/introc5.htm

I have had no problems with having Cold Fusion create/manage my collections that I have done for online e-commerce search engines.

There is good documentation/examples in the COld Fusion books by Forta Weiss, et all.  There are examples of doing exactly what you are asking for.
0
 
LVL 4

Author Comment

by:Ike23
Comment Utility
Do you have the names of the books or websites with the examples?

CFDevHead gave me some stuff to get started but I am worried about how I will do a <cfif> around each folder or document to make sure that the person doing the search has permission to read documents within that folder.  I have a database structure that keeps folders and roles and also the userid of the person.  I could probably solve the security problem if I only allowed the folders that the user can view to be used in the collection.  Is it a bad practice to create a collection on the fly for every user?  What about folders within folders?  I have all my folders in a main docfolder/ and then inside that I have a folder created for each customer by their customerid in the database.  Inside each customer folder can be a bunch of other folders that are also named with numbers that correspond to my folders table in the database.  So if I wanted to search documents for customer number 23 it would look like this  c:/docfolder/23/400 (customer 23 project 400).   This way I can avoid having direct paths to my documents using links and instead I use CFCONTENT to get the document for me.  I have the folderid as a foreign key in the document table so I just pass the document ID to my "document finder" page like this:  docfinder.cfm?docid=#docid#  Then I can do a check to see if the person has the correct role to view the document before I display it...  <cfif IsUserInRole("Administrator") OR LISTFIND(#folderid#_1,#session.user_roles#)>

This is kind of confusing sorry.  It's been a challenge for me to say the least.  Is there a way to combine the information from my database and the verity search?  I guess what I really need is to know the folder name that the document resides in and then I can do a <cfif> around each document before I display it to the user.  Does this make any sense?
0
 
LVL 9

Expert Comment

by:CFDevHead
Comment Utility
When outputing the results you could test for the directory name and dislpay it or not display it.
0
 
LVL 4

Author Comment

by:Ike23
Comment Utility
What about defining exactly what folder should be searched?  Is that an option or is that something I should forget about and move on?  THanks.
0
 
LVL 9

Expert Comment

by:CFDevHead
Comment Utility
>>"What about defining exactly what folder should be searched? "
you could define exactly what folder should be searched based on the user id if you want but then you will have a collection per user. its up you.
0
 
LVL 35

Expert Comment

by:mrichmon
Comment Utility
The books are "Cold Fusion Web Application Kit" and "Cold Fusion Advanced Application Development"
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 4

Author Comment

by:Ike23
Comment Utility
Creating a collection per user probably isn't a good idea I am guessing.  How would I specify which folders inside of the main docfolder to index anyway?  I'll this stuff out today and see what problems I run into.
0
 
LVL 4

Author Comment

by:Ike23
Comment Utility
Ok, I am pretty confident that I can get a Verity collection created and searched.  I don't seem to see any values returned by cfsearch that indicate what folder a document was residing in.  I think that the full path is returned though.  Is there a way to create the collection using a folder mapping and then create an index of my corresponding database table and somehow relate the output so that I can tell if the user has permission to view documents within the folder?  

A few more questions...   Do I need to update my collection every time a document is uploaded or moved or does the collection just look in the folder specified and run a new search each time?  
What happens if a movie file or music file is uploaded.  Will that be indexed as well?
0
 
LVL 4

Author Comment

by:Ike23
Comment Utility
So I created the collection and indexed it.  Then I figured out a way to get the database record by comparing the #Key# value to the full path I have saved in the database.  That works but I have to query the database for each document which kind of puts a hit on the server.  I limited the maxrows to 10 so that shouldn't be too bad of a performance hit.  Now I can compare the user's permission on the folder that the document is in and only show documents that the user is allowed to see.  Pretty crazy but I guess if the key is unique (which a path to a file has to be) then it is as good as a primary key and I can use it to retrieve my related database record.  

Now I'm wondering about when a person adds/updates/moves a document.  Do I need to update the collection every time something changes?  I read that sometimes the collection gets messed up when you do a lot of updates.  Then you have to do a repair or something.  Is that what I should expect?  Would you recommend updating the collection every time something changes or just having a scheduled task run the update every day or something?  I would prefer that the document would be searchable after something is added to it or the first time it is uploaded but I don't want to sacrifice my system's stability to do so.  

Thanks for all your help getting me started!
0
 
LVL 4

Author Comment

by:Ike23
Comment Utility
Does anyone know if I need to update the collection every time a new document is uploaded or if a document is changed?  If so would I use the CFINDEX tag to update the collection?  I saw the option in the CFCOLLECTION tag to "optimize" the collection.  What is this for?  Would that take the place of updating the collection or would I need to use both?  Thanks for any input!


-Tim
0
 
LVL 9

Expert Comment

by:CFDevHead
Comment Utility
yes you need to update your collection everytime a document is uploaded

here is so code
<CFINDEX
      collection="#IndexCollection#"
    action="UPDATE"
    type="PATH"
    key="#IndexDirectory#\"
    extensions="#IndexExtensions#"
    recurse="#IndexRecurse#"
    language="#IndexLanguage#"
      urlPath="http://intranet.mysite.com/"
>
for ColdFusion MX: The action attribute value optimize is obsolete in.
0
 
LVL 4

Author Comment

by:Ike23
Comment Utility
Do you need to include the extensions, recurse, language, urlPath everytime?  So CF MX automatically optimizes the collection each time?  I have a CFMX developers study guide that recommends to optimize often since updating a lot fragments the collection.  Is that something new with 6.1?
0
 
LVL 9

Expert Comment

by:CFDevHead
Comment Utility
Do you need to include the extensions, recurse, language, urlPath everytime?No

So CF MX automatically optimizes the collection each time?I don't Know

 I have a CFMX developers study guide that recommends to optimize often since updating a lot fragments the collection.  Is that something new with 6.1?
http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-p64.htm
0

Featured Post

Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

Join & Write a Comment

Suggested Solutions

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now