r143 - in trunk: cantharella.data/src/main/java/nc/ird/cantharella/data/model cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl
Author: echatellier Date: 2013-02-21 12:32:04 +0100 (Thu, 21 Feb 2013) New Revision: 143 Url: http://forge.codelutin.com/projects/cantharella/repository/revisions/143 Log: Exlude id from search query parser Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Campagne.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Extraction.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Lot.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MethodeTestBio.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Produit.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Purification.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Specimen.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Station.java trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/TestBio.java trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Campagne.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Campagne.java 2013-02-21 09:37:08 UTC (rev 142) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Campagne.java 2013-02-21 11:32:04 UTC (rev 143) @@ -49,9 +49,7 @@ import org.hibernate.annotations.Cascade; import org.hibernate.annotations.CascadeType; import org.hibernate.annotations.Type; -import org.hibernate.search.annotations.Analyze; import org.hibernate.search.annotations.Field; -import org.hibernate.search.annotations.Index; import org.hibernate.search.annotations.Store; import org.hibernate.validator.constraints.Length; import org.hibernate.validator.constraints.NotEmpty; @@ -76,7 +74,7 @@ @NotNull @NotEmpty @Length(max = LENGTH_MEDIUM_TEXT) - @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) + @Field(store = Store.YES) private String nom; /** Code pays */ Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Extraction.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Extraction.java 2013-02-21 09:37:08 UTC (rev 142) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Extraction.java 2013-02-21 11:32:04 UTC (rev 143) @@ -52,12 +52,10 @@ import org.hibernate.annotations.Cascade; import org.hibernate.annotations.CascadeType; import org.hibernate.annotations.Type; -import org.hibernate.search.annotations.Analyze; import org.hibernate.search.annotations.ContainedIn; import org.hibernate.search.annotations.Field; import org.hibernate.search.annotations.FullTextFilterDef; import org.hibernate.search.annotations.FullTextFilterDefs; -import org.hibernate.search.annotations.Index; import org.hibernate.search.annotations.Indexed; import org.hibernate.search.annotations.IndexedEmbedded; import org.hibernate.search.annotations.Store; @@ -82,7 +80,7 @@ @Length(max = LENGTH_MEDIUM_TEXT) @Column(unique = true) @NotEmpty - @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) + @Field(store = Store.YES) private String ref; /** Manipulateur */ Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Lot.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Lot.java 2013-02-21 09:37:08 UTC (rev 142) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Lot.java 2013-02-21 11:32:04 UTC (rev 143) @@ -50,11 +50,9 @@ import org.apache.commons.beanutils.BeanComparator; import org.hibernate.annotations.Type; -import org.hibernate.search.annotations.Analyze; import org.hibernate.search.annotations.Field; import org.hibernate.search.annotations.FullTextFilterDef; import org.hibernate.search.annotations.FullTextFilterDefs; -import org.hibernate.search.annotations.Index; import org.hibernate.search.annotations.Indexed; import org.hibernate.search.annotations.IndexedEmbedded; import org.hibernate.search.annotations.Store; @@ -82,7 +80,7 @@ @Column(unique = true) @NotEmpty @Length(max = LENGTH_MEDIUM_TEXT) - @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) + @Field(store = Store.YES) private String ref; /** Campagne */ Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MethodeTestBio.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MethodeTestBio.java 2013-02-21 09:37:08 UTC (rev 142) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/MethodeTestBio.java 2013-02-21 11:32:04 UTC (rev 143) @@ -33,10 +33,7 @@ import org.apache.commons.beanutils.BeanComparator; import org.hibernate.annotations.Type; -import org.hibernate.search.annotations.Analyze; import org.hibernate.search.annotations.Field; -import org.hibernate.search.annotations.Index; -import org.hibernate.search.annotations.Store; import org.hibernate.validator.constraints.Length; import org.hibernate.validator.constraints.NotEmpty; @@ -57,14 +54,14 @@ @Length(max = LENGTH_MEDIUM_TEXT) @Column(unique = true) @NotEmpty - @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) + @Field private String nom; /** Cible pour un test (acronyme du nom de méthode) */ @Length(max = LENGTH_MEDIUM_TEXT) @Column(unique = true) @NotEmpty - @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) + @Field private String cible; /** Domaine de recherche pour le test */ Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java 2013-02-21 09:37:08 UTC (rev 142) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Molecule.java 2013-02-21 11:32:04 UTC (rev 143) @@ -48,14 +48,11 @@ import org.hibernate.annotations.Cascade; import org.hibernate.annotations.CascadeType; import org.hibernate.annotations.Type; -import org.hibernate.search.annotations.Analyze; import org.hibernate.search.annotations.Field; import org.hibernate.search.annotations.FullTextFilterDef; import org.hibernate.search.annotations.FullTextFilterDefs; -import org.hibernate.search.annotations.Index; import org.hibernate.search.annotations.Indexed; import org.hibernate.search.annotations.IndexedEmbedded; -import org.hibernate.search.annotations.Store; import org.hibernate.validator.constraints.Length; import org.hibernate.validator.constraints.NotEmpty; @@ -77,12 +74,12 @@ /** Nom commun */ @Length(max = LENGTH_LONG_TEXT) - @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) + @Field private String nomCommun; /** Famille chimique */ @Length(max = LENGTH_MEDIUM_TEXT) - @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) + @Field private String familleChimique; /** Famille developpée */ @@ -93,7 +90,7 @@ /** Nom IUPAC */ @Length(max = LENGTH_BIG_TEXT) - @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) + @Field private String nomIupca; /** Formule brute */ @@ -117,7 +114,7 @@ /** Identifiee par. */ @Length(max = LENGTH_MEDIUM_TEXT) - @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) + @Field private String identifieePar; /** Publication d'origine */ Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Produit.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Produit.java 2013-02-21 09:37:08 UTC (rev 142) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Produit.java 2013-02-21 11:32:04 UTC (rev 143) @@ -43,7 +43,6 @@ import nc.ird.cantharella.data.model.utils.AbstractModel; import org.apache.commons.beanutils.BeanComparator; -import org.hibernate.search.annotations.Analyze; import org.hibernate.search.annotations.ClassBridge; import org.hibernate.search.annotations.ContainedIn; import org.hibernate.search.annotations.Field; @@ -70,7 +69,7 @@ @Length(max = LENGTH_MEDIUM_TEXT) @NotEmpty @Column(unique = true) - @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) + @Field(store = Store.YES) private String ref; /** Masse obtenue pour le produit **/ Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Purification.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Purification.java 2013-02-21 09:37:08 UTC (rev 142) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Purification.java 2013-02-21 11:32:04 UTC (rev 143) @@ -54,11 +54,9 @@ import org.hibernate.annotations.Cascade; import org.hibernate.annotations.CascadeType; import org.hibernate.annotations.Type; -import org.hibernate.search.annotations.Analyze; import org.hibernate.search.annotations.Field; import org.hibernate.search.annotations.FullTextFilterDef; import org.hibernate.search.annotations.FullTextFilterDefs; -import org.hibernate.search.annotations.Index; import org.hibernate.search.annotations.Indexed; import org.hibernate.search.annotations.IndexedEmbedded; import org.hibernate.search.annotations.Store; @@ -83,7 +81,7 @@ @Length(max = LENGTH_MEDIUM_TEXT) @Column(unique = true) @NotEmpty - @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) + @Field(store = Store.YES) private String ref; /** Manipulateur */ Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Specimen.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Specimen.java 2013-02-21 09:37:08 UTC (rev 142) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Specimen.java 2013-02-21 11:32:04 UTC (rev 143) @@ -44,11 +44,9 @@ import org.apache.commons.beanutils.BeanComparator; import org.hibernate.annotations.Type; -import org.hibernate.search.annotations.Analyze; import org.hibernate.search.annotations.Field; import org.hibernate.search.annotations.FullTextFilterDef; import org.hibernate.search.annotations.FullTextFilterDefs; -import org.hibernate.search.annotations.Index; import org.hibernate.search.annotations.Indexed; import org.hibernate.search.annotations.IndexedEmbedded; import org.hibernate.search.annotations.Store; @@ -96,28 +94,28 @@ @Column(unique = true) @NotEmpty @Length(max = LENGTH_TINY_TEXT) - @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) + @Field(store = Store.YES) private String ref; /** Embranchement */ @Length(max = LENGTH_MEDIUM_TEXT) @NotEmpty - @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) + @Field private String embranchement; /** Famille */ @Length(max = LENGTH_MEDIUM_TEXT) - @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) + @Field private String famille; /** Genre */ @Length(max = LENGTH_MEDIUM_TEXT) - @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) + @Field private String genre; /** Espèce */ @Length(max = LENGTH_MEDIUM_TEXT) - @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) + @Field private String espece; /** Sous-espèce */ Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Station.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Station.java 2013-02-21 09:37:08 UTC (rev 142) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/Station.java 2013-02-21 11:32:04 UTC (rev 143) @@ -48,14 +48,11 @@ import org.apache.commons.beanutils.BeanComparator; import org.hibernate.annotations.AccessType; import org.hibernate.annotations.Type; -import org.hibernate.search.annotations.Analyze; import org.hibernate.search.annotations.Field; import org.hibernate.search.annotations.FullTextFilterDef; import org.hibernate.search.annotations.FullTextFilterDefs; -import org.hibernate.search.annotations.Index; import org.hibernate.search.annotations.Indexed; import org.hibernate.search.annotations.IndexedEmbedded; -import org.hibernate.search.annotations.Store; import org.hibernate.validator.constraints.Length; import org.hibernate.validator.constraints.NotEmpty; @@ -81,14 +78,14 @@ @Column(unique = true) @NotEmpty @Length(max = LENGTH_MEDIUM_TEXT) - @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) + @Field private String nom; /** Code pays */ @NotNull @Length(min = 2, max = 2) @CountryCode - @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) + @Field private String codePays; /** Complément */ @@ -105,7 +102,7 @@ /** Localité */ @Length(max = LENGTH_MEDIUM_TEXT) - @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) + @Field private String localite; /** Latitude */ Modified: trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/TestBio.java =================================================================== --- trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/TestBio.java 2013-02-21 09:37:08 UTC (rev 142) +++ trunk/cantharella.data/src/main/java/nc/ird/cantharella/data/model/TestBio.java 2013-02-21 11:32:04 UTC (rev 143) @@ -56,10 +56,8 @@ import org.hibernate.annotations.Cascade; import org.hibernate.annotations.CascadeType; import org.hibernate.annotations.Type; -import org.hibernate.search.annotations.Analyze; import org.hibernate.search.annotations.ContainedIn; import org.hibernate.search.annotations.Field; -import org.hibernate.search.annotations.Index; import org.hibernate.search.annotations.IndexedEmbedded; import org.hibernate.search.annotations.Store; import org.hibernate.validator.constraints.Length; @@ -82,7 +80,7 @@ @Length(max = LENGTH_MEDIUM_TEXT) @Column(unique = true) @NotEmpty - @Field(index = Index.YES, analyze = Analyze.YES, store = Store.YES) + @Field(store = Store.YES) private String ref; /** Manipulateur */ Modified: trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java =================================================================== --- trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java 2013-02-21 09:37:08 UTC (rev 142) +++ trunk/cantharella.service/src/main/java/nc/ird/cantharella/service/services/impl/SearchServiceImpl.java 2013-02-21 11:32:04 UTC (rev 143) @@ -22,6 +22,7 @@ */ package nc.ird.cantharella.service.services.impl; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -187,11 +188,17 @@ // build a multi field query parser to search in all fields IndexReader reader = searchFactory.getIndexReaderAccessor().open(clazz); FieldInfos fieldInfos = ReaderUtil.getMergedFieldInfos(reader); - String[] fieldArray = new String[fieldInfos.size()]; + List<String> fieldList = new ArrayList<>(); for (int i = 0; i < fieldInfos.size(); i++) { - fieldArray[i] = fieldInfos.fieldName(i); + String fieldName = fieldInfos.fieldName(i); + // il semble impossible de ne pas recuperer l'id du document + // on l'exclut donc manuellement + if (!fieldName.startsWith("id") && !fieldName.contains(".id")) { + fieldList.add(fieldInfos.fieldName(i)); + } } - QueryParser parser = new MultiFieldQueryParser(Version.LUCENE_36, fieldArray, searchFactory.getAnalyzer(clazz)); + QueryParser parser = new MultiFieldQueryParser(Version.LUCENE_36, fieldList.toArray(new String[fieldList.size()]), + searchFactory.getAnalyzer(clazz)); searchFactory.getIndexReaderAccessor().close(reader); // autorisation de "*" en premier caractere
participants (1)
-
echatellier@users.forge.codelutin.com