adding doc for the search framework
[mir.git] / doc / developers-guide / search.xml
1 <chapter id="search_framework">
2 <title>Search Framework</title>
3 Please read the short presentation of the <glossterm linkend="search">search framework</glossterm> for an introduction. You can also check the javadoc.
4 <section><title>The SearchTerm class</title>
5 The SearchTerm class attempts to encapsulate the relationships
6 between:
7 <itemizedlist>
8 <listitem>A fields or property of Content Entities </listitem>
9 <listitem>A field of Lucene Documents</listitem>
10 <listitem>An HTTP Query Parameter</listitem>
11 <listitem>And a bit of HTML on a Search Results Page    </listitem>
12 </itemizedlist>
13 <para>
14 The  basic  idea  is that  how  you  index,  query, and  display  a
15 particular field in a resource are all intimately related, possibly
16 more  so  than how  you  index two  different  fields  of the  same
17 resource.
18 </para>
19 <para>
20 Instances of classes implementing SearchTerm are created when a Mir
21 content entity  is indexed by the  IndexingProducerNode Class.  The
22 index  method of  each class  is called  in turn  to add  a  bit of
23 information  to the  Lucene documents  which will  be added  to the
24 index after it is created  and all its fields specified.  Instances
25 of the same classes are created by ServletModuleOpenIndy so that it
26 can construct a  query to match against the  lucene index, here the
27 makeTerm methods are called in  turn to pick out the parameter they
28 want from  the request and then construct  the appropriate fragment
29 of lucene query, which are ultimately concatenated together.  These
30 classes  are  also  used  to  return  appropriate  template  models
31 representing any hits to be displayed as a result of processing the
32 query.
33 </para>
34 </section>
35 <section><title>Available search classes</title>
36 <variablelist>
37 <varlistentry>
38 <term><classname>ContentSearchTerm</classname></term><listitem>tokenizes a string field in an Entity and indexes
39 it, but does not store it for retrieval (used for content_data)
40 </listitem></varlistentry>
41
42 <varlistentry>
43 <term><classname>ImagesSearchTerm</classname></term><listitem>indexes whether or not an Entity has associated
44 images, and also stores urls of those images for retrieval in the search results
45 </listitem></varlistentry>
46 <varlistentry>
47 <term><classname>KeywordSearchTerm</classname></term><listitem>indexes a field and stores it for retrieval, but
48 does not tokenize it.  useful for things like strings representing
49 dates.
50 </listitem></varlistentry>
51 <varlistentry>
52 <term><classname>MediaSearchTerm</classname></term><listitem>not used
53 </listitem></varlistentry>
54 <varlistentry>
55 <term><classname>AudioSearchTerm</classname></term><listitem>indexes whether an Enity has audio 
56 </listitem></varlistentry>
57 <varlistentry>
58 <term><classname>VideoSearchTerm</classname></term><listitem>indexes whether an Enity has video
59 </listitem></varlistentry>
60 <varlistentry>
61 <term><classname>TextSearchTerm</classname></term><listitem>tokenizes a string field in an Entity and indexes
62 it, and stores it for retrieval (used for description)
63 </listitem></varlistentry>
64 <varlistentry>
65 <term><classname>TopicSearchTerm</classname></term><listitem>used by indexing and querying documents based on Topic
66 </listitem></varlistentry>
67 <varlistentry>
68 <term><classname>UnIndexedSearchTerm</classname></term><listitem>Stores some metatdata for retrieval with a hit (for example a URL)  
69 </listitem></varlistentry>
70 <varlistentry>
71 <term><classname>UnStoredSearchTerm</classname></term><listitem>not currently used
72 </listitem></varlistentry>
73 </variablelist>
74
75 </section>
76 <section><title>Lucene field types</title>
77 <para>
78 The  following brief  guide  to  lucene field  types  is invaluable  in
79 figuring out what a particular SearchTerm does:
80 </para>
81
82          Keyword is stored and indexed, but not tokenized
83          Text is tokenized,stored, indexed
84          Unindexed is not tokenized or indexed, only stored
85          Unstored is tokenized and indexed, but not stored
86
87 </section>
88
89 </chapter>