[opencms-dev] Simple Search 1.4 with user name in the search field produces strange results

M Butcher mbutcher at grcomputing.net
Fri Nov 21 18:43:01 CET 2003


Hartmann, Waehrisch & Feykes GmbH wrote:
> Hi,
> 
> for the newsDocument i was putting all fields like title and description and
> i think also the author into the body, more as a hack.
> 
> Bye,
> Stephan


Ah, yes... that makes sense. I was assuming that the objects were Page 
documents.

Trevor, you can fix that by just commenting out the lines:

if (auth!=null) {
         doc.add(Field.Text(FIELD_AUTHOR, auth));
         doc.add(Field.UnStored(FIELD_BODY, auth));
     }

in net/grcomputing/opencms/search/lucene/NewsDocument.java and 
recompiling the module.

I guess I really ought to build a better SimpleSearch....

Matt

> 
> 
> ----- Original Message ----- 
> From: "Trevor Lee" <Trevor.Lee at 4Loop.com.au>
> To: <opencms-dev at opencms.org>
> Sent: Friday, November 21, 2003 5:35 AM
> Subject: [opencms-dev] Simple Search 1.4 with user name in the search field
> produces strange results
> 
> 
> 
>>Hi,
>>
>>I was wondering whether anyone else has experienced the problem with
> 
> simple
> 
>>search (using lucene 1.4) where entering a user name eg. "admin" and
> 
> search
> 
>>on that. It returns all articles created by admin in this instance.
>>I've prefixed the term with "body:".
>>
>>What could be causing this behaviour?
>>
>>the doSimpleSearch() method is the one below (as in SearchHelper.java):
>>
>>I've included my registry file below....
>>public Hits doSimpleSearch(String term) throws CmsException {
>>try {
>>Searcher s = new IndexSearcher(getIndexPath());
>>Query q = null;
>>Analyzer analyzer = new StopAnalyzer();
>>
>>q = QueryParser.parse(term, FIELD_BODY, analyzer);
>>Hits hits = s.search(q);
>>return hits;
>>} catch (java.io.IOException ioe) {
>>throw new CmsException("Error searching", ioe);
>>} catch (org.apache.lucene.queryParser.ParseException pe) {
>>throw new CmsException("Error parsing search string", pe);
>>}
>>}
>>
>>Registry.xml
>>        <luceneSearch>
>>            <mergeFactor>100000</mergeFactor>
>>            <permCheck>true</permCheck>
>>
>>
> <indexDir>C:\Jakarta-Tomcat-4.1.12\webapps\opencms\lucene\index\</indexDir>
> 
>><analyzer>org.apache.lucene.analysis.standard.StandardAnalyzer</analyzer>
>>            <subsearch>true</subsearch>
>>            <project>online</project>
>>            <docFactories>
>>                <docFactory enabled="true" type="page">
>>
>><class>net.grcomputing.opencms.search.lucene.PageDocument</class>
>>                </docFactory>
>>                <docFactory enabled="true" type="plain">
>>                    <fileType name="plaintext">
>>                        <extension>.txt</extension>
>>
>><class>net.grcomputing.opencms.search.lucene.PlainDocument</class>
>>                    </fileType>
>>                    <fileType name="taggedtext">
>>                        <extension>.html</extension>
>>                        <extension>.htm</extension>
>>                        <extension>.xml</extension>
>>                        <!-- This will strip tags before processing -->
>>
>><class>net.grcomputing.opencms.search.lucene.TaggedPlainDocument</class>
>>                    </fileType>
>>                </docFactory>
>>                <docFactory enabled="true" type="binary">
>>
>><class>net.grcomputing.opencms.search.lucene.BodylessDocument</class>
>>                </docFactory>
>>                <docFactory enabled="true" type="jsp">
>>
>><class>net.grcomputing.opencms.search.lucene.JspDocument</class>
>>                </docFactory>
>>                <docFactory enabled="true" type="news">
>>
>><class>net.grcomputing.opencms.search.lucene.NewsDocument</class>
>>                </docFactory>
>>                <docFactory enabled="false" type="XML Template"/>
>>            </docFactories>
>>            <directories>
>>                <directory location="/SWM/">
>>                    <section>Test</section>
>>                    <subsearch>true</subsearch>
>>                </directory>
>>            </directories>
>>            <contentDefinitions>
>>                <contentDefinition type="news">
>>
>><class>com.opencms.modules.homepage.news.NewsContentDefinition</class>
>>
>>
> <initClass>net.grcomputing.opencms.search.lucene.NewsInitialization</initCla
> 
>>ss>
>>                    <listMethod name="getSortedList">
>>                        <param type="java.lang.String"/>
>>                    </listMethod>
>>                    <page uri="/SoftwareMark/auth/news/news.jsp">
>>                        <param method="getIntId" name="id"/>
>>                    </page>
>>                </contentDefinition>
>>            </contentDefinitions>
>>        </luceneSearch>
>>
>>Thank you
>>Trevor
>>
>>_______________________________________________
>>This mail is send to you from the opencms-dev mailing list
>>To change your list options, or to unsubscribe from the list, please visit
>>http://mail.opencms.org/mailman/listinfo/opencms-dev
> 
> 
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://mail.opencms.org/mailman/listinfo/opencms-dev





More information about the opencms-dev mailing list