Hi all

Just to finish with lucene

For multiple searches in particular field in a containerList you have 2 
possibilities.

Download the new Java class and replace in the Jahia.jar.
        ChainedJahiaSearcher.java
        ContainerFactory.java
        JahiaSearcher.java
 Then you just have to do the search

ContainerSearcher ContainerSearcher1= new 
ContainerSearcher(jData.params().getSiteID(), "", query1, 
jData.params().getEntryLoadRequest());
ContainerSearcher ContainerSearcher2= new 
ContainerSearcher(jData.params().getSiteID(), "", query2, 
jData.params().getEntryLoadRequest());

ChainedJahiaSearcher chainedSearcher = new ChainedJahiaSearcher(new 
JahiaSearcher[]{ContainerSearcher1, 
ContainerSearcher2},ChainedJahiaSearcher.AND);
JahiaSearchResult 
jSearchResultChained=chainedSearcher.search(chainedSearcher.getQuery(),jParams);


The second possibility is to use directly the lucene syntax

(fieldname:field1 AND value:XXXX) INTERSECT (fieldname:field2 AND value:YYYYY)

This command seems work good.

Nicolas


-----Message d'origine-----
De : Khue Nguyen [mailto:[EMAIL PROTECTED] 
Envoyé : lundi 18 juillet 2005 16:59
À : [email protected]
Objet : Re: Probleme lucene

Hi,

please, see below the response given to one of our customer about similar 
issue.

Regards,
Khue Nguyen



>----- Original Message ----- 
>From: Khue Nguyen
>To: [EMAIL PROTECTED]
>Sent: Tuesday, July 05, 2005 11:36 AM
>Subject: Re: About Lucene query


>Hello Alessandro,


>unfortunately none of these queries actually work because the unit of 
>indexation is field, not container nor page.
>We may index by container as well in future refactoring of the search 
>engine.

>At least, I just added to the cvs ( last version of jahia 4.0.6 and jahia 
>4.1), a ChainedJahiaSearcher class that allow you to combine and, or, xor 
>logics  >((a or b) and c) ... between several searchers, so that you can 
>search on several fields of a same container. What you are trying to do.
>Note that there is a org.jahia.data.containers.ContainerChainedFilter that 
>works in the same way but for Container filters ( only with last version of 
>Jahia >4.1 ).

>Below is an example of search performed on the firstname field and lastname 
>field of the people container.

> // first name searcher
> String firstNameQuery = "toto AND fieldname:firsname";
> ContainerSearcher firstNameSearcher =
> new ContainerSearcher("directoryPeopleContainer",jParams,firstNameQuery 
> ,jParams.getEntryLoadRequest());

> // last name searcher
> String lastNameQuery = "mc* AND fieldname:lastname";
> ContainerSearcher lastNameSearcher =
> new ContainerSearcher("directoryPeopleContainer",jParams,lastNameQuery 
> ,jParams.getEntryLoadRequest());

> // chaining searcher
> ChainedJahiaSearcher chainedSearcher = new ChainedJahiaSearcher(
>  new 
> JahiaSearcher[]{firstNameSearcher,lastNameSearcher},ChainedJahiaSearcher.AND);
>  
> // may be OR, ANDNOT, XOR, ...
> request.setAttribute("directoryPeopleContainer_search_handler",chainedSearcher);





----- Original Message ----- 
From: "Nicolas Lafaury" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, July 18, 2005 3:40 PM
Subject: Probleme lucene


Hi all

I want search a name in a particular field.

This is my containerList definition.


<content:declareContainerList name='myLuceneContainerList'
  title="myContainerList"
>
  <content:declareContainer>
    <content:declareField name='number'
      title="number"
      type="SmallText"
    />
    <content:declareField name='title'
      title="title"
      type="SmallText"
    />
  </content:declareContainer>
</content:declareContainerList>


I want retrieve all containers where the field "title" is equal to
"Hello".

The syntax to search is :

Hello AND fieldname: title.

But my problem is how I can find all containers where the field "number"
is equals to "2" and the field "title" is equal to "hello".

Is anyone has a idea?

Thanks.

Nicolas


Reply via email to