branch develop updated (c3c90ba -> ccb5f72)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git from c3c90ba Refs #6746 : Little display modification for tooltip new 135d795 use wildcard query on document name, summary and authors and on question name and summary for lucene search new ccb5f72 Merge branch 'develop' of https://git.codelutin.com/coselmar into develop The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit ccb5f72d7c83b70242ec671b350672f214ba1837 Merge: 135d795 c3c90ba Author: Yannick Martel <martel@©odelutin.com> Date: Mon Mar 2 18:24:21 2015 +0100 Merge branch 'develop' of https://git.codelutin.com/coselmar into develop commit 135d795a29f7ce99089dca5a814a0515a902cee6 Author: Yannick Martel <martel@©odelutin.com> Date: Mon Mar 2 18:23:32 2015 +0100 use wildcard query on document name, summary and authors and on question name and summary for lucene search Summary of changes: .../indexation/DocumentsIndexationService.java | 28 ++++++++++++---------- .../indexation/QuestionsIndexationService.java | 13 +++++----- .../indexation/DocumentsIndexationServiceTest.java | 10 ++++++++ 3 files changed, 31 insertions(+), 20 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit 135d795a29f7ce99089dca5a814a0515a902cee6 Author: Yannick Martel <martel@©odelutin.com> Date: Mon Mar 2 18:23:32 2015 +0100 use wildcard query on document name, summary and authors and on question name and summary for lucene search --- .../indexation/DocumentsIndexationService.java | 28 ++++++++++++---------- .../indexation/QuestionsIndexationService.java | 13 +++++----- .../indexation/DocumentsIndexationServiceTest.java | 10 ++++++++ 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/DocumentsIndexationService.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/DocumentsIndexationService.java index a280517..af3b62a 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/DocumentsIndexationService.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/DocumentsIndexationService.java @@ -41,9 +41,9 @@ import org.apache.lucene.queryparser.classic.ParseException; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.PhraseQuery; import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.TermQuery; +import org.apache.lucene.search.WildcardQuery; /** * This Services provides operation about {@link fr.ifremer.coselmar.persistence.entity.Document} @@ -99,14 +99,15 @@ public class DocumentsIndexationService extends CoselmarSimpleServiceSupport { // Parse a simple query that searches for the "text": BooleanQuery query = new BooleanQuery(); - PhraseQuery nameQuery = new PhraseQuery(); - PhraseQuery summaryQuery = new PhraseQuery(); - PhraseQuery authorsQuery = new PhraseQuery(); + BooleanQuery nameQuery = new BooleanQuery(); + BooleanQuery summaryQuery = new BooleanQuery(); + BooleanQuery authorsQuery = new BooleanQuery(); for (String word : words) { - nameQuery.add(new Term(DOCUMENT_NAME_INDEX_PROPERTY, word.toLowerCase())); - summaryQuery.add(new Term(DOCUMENT_SUMMARY_INDEX_PROPERTY, word.toLowerCase())); - authorsQuery.add(new Term(DOCUMENT_AUTHORS_INDEX_PROPERTY, word.toLowerCase())); + String wildWord = String.format("*%s*", word.toLowerCase()); + nameQuery.add(new WildcardQuery(new Term(DOCUMENT_NAME_INDEX_PROPERTY, wildWord)), BooleanClause.Occur.MUST); + summaryQuery.add(new WildcardQuery(new Term(DOCUMENT_SUMMARY_INDEX_PROPERTY, wildWord)), BooleanClause.Occur.MUST); + authorsQuery.add(new WildcardQuery(new Term(DOCUMENT_AUTHORS_INDEX_PROPERTY, wildWord)), BooleanClause.Occur.MUST); } query.add(nameQuery, BooleanClause.Occur.SHOULD); @@ -148,14 +149,15 @@ public class DocumentsIndexationService extends CoselmarSimpleServiceSupport { // Parse a simple query that searches for the "text": BooleanQuery query = new BooleanQuery(); - PhraseQuery nameQuery = new PhraseQuery(); - PhraseQuery summaryQuery = new PhraseQuery(); - PhraseQuery authorsQuery = new PhraseQuery(); + BooleanQuery nameQuery = new BooleanQuery(); + BooleanQuery summaryQuery = new BooleanQuery(); + BooleanQuery authorsQuery = new BooleanQuery(); for (String word : words) { - nameQuery.add(new Term(DOCUMENT_NAME_INDEX_PROPERTY, word.toLowerCase())); - summaryQuery.add(new Term(DOCUMENT_SUMMARY_INDEX_PROPERTY, word.toLowerCase())); - authorsQuery.add(new Term(DOCUMENT_AUTHORS_INDEX_PROPERTY, word.toLowerCase())); + String wildWord = "*" + word.toLowerCase() + "*"; + nameQuery.add(new WildcardQuery(new Term(DOCUMENT_NAME_INDEX_PROPERTY, wildWord)), BooleanClause.Occur.MUST); + summaryQuery.add(new WildcardQuery(new Term(DOCUMENT_SUMMARY_INDEX_PROPERTY, wildWord)), BooleanClause.Occur.MUST); + authorsQuery.add(new WildcardQuery(new Term(DOCUMENT_AUTHORS_INDEX_PROPERTY, wildWord)), BooleanClause.Occur.MUST); } query.add(nameQuery, BooleanClause.Occur.SHOULD); diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/QuestionsIndexationService.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/QuestionsIndexationService.java index f6e9f65..36bffef 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/QuestionsIndexationService.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/QuestionsIndexationService.java @@ -43,9 +43,9 @@ import org.apache.lucene.queryparser.classic.ParseException; import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.PhraseQuery; import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.TermQuery; +import org.apache.lucene.search.WildcardQuery; /** * This Services provides operation about {@link fr.ifremer.coselmar.persistence.entity.Document} @@ -167,18 +167,17 @@ public class QuestionsIndexationService extends CoselmarSimpleServiceSupport { // Parse a simple query that searches for the "text": BooleanQuery query = new BooleanQuery(); - PhraseQuery nameQuery = new PhraseQuery(); - PhraseQuery summaryQuery = new PhraseQuery(); - PhraseQuery authorsQuery = new PhraseQuery(); + BooleanQuery nameQuery = new BooleanQuery(); + BooleanQuery summaryQuery = new BooleanQuery(); for (String word : words) { - nameQuery.add(new Term(QUESTION_TITLE_INDEX_PROPERTY, word.toLowerCase())); - summaryQuery.add(new Term(QUESTION_SUMMARY_INDEX_PROPERTY, word.toLowerCase())); + String wildWord = String.format("*%s*", word.toLowerCase()); + nameQuery.add(new WildcardQuery(new Term(QUESTION_TITLE_INDEX_PROPERTY, wildWord)), BooleanClause.Occur.MUST); + summaryQuery.add(new WildcardQuery(new Term(QUESTION_SUMMARY_INDEX_PROPERTY, wildWord)), BooleanClause.Occur.MUST); } query.add(nameQuery, BooleanClause.Occur.SHOULD); query.add(summaryQuery, BooleanClause.Occur.SHOULD); - query.add(authorsQuery, BooleanClause.Occur.SHOULD); query.add(new TermQuery(new Term(QUESTION_THEME_INDEX_PROPERTY, text.toLowerCase())), BooleanClause.Occur.SHOULD); diff --git a/coselmar-rest/src/test/java/fr/ifremer/coselmar/services/indexation/DocumentsIndexationServiceTest.java b/coselmar-rest/src/test/java/fr/ifremer/coselmar/services/indexation/DocumentsIndexationServiceTest.java index eff808f..c08624a 100644 --- a/coselmar-rest/src/test/java/fr/ifremer/coselmar/services/indexation/DocumentsIndexationServiceTest.java +++ b/coselmar-rest/src/test/java/fr/ifremer/coselmar/services/indexation/DocumentsIndexationServiceTest.java @@ -95,6 +95,16 @@ public class DocumentsIndexationServiceTest extends AbstractCoselmarServiceTest Assert.assertEquals(1, documentMatchingPartOfSummaryIds.size()); Assert.assertEquals("document3", documentMatchingPartOfSummaryIds.get(0)); + List<String> documentMatchingPartOfWordIds = documentsIndexationService.searchDocuments("documenta"); + Assert.assertEquals(1, documentMatchingPartOfWordIds.size()); + Assert.assertEquals("document3", documentMatchingPartOfWordIds.get(0)); + + documentMatchingPartOfWordIds = documentsIndexationService.searchDocuments("Thi"); + Assert.assertEquals(3, documentMatchingPartOfWordIds.size()); + Assert.assertTrue(documentMatchingPartOfWordIds.contains("document1")); + Assert.assertTrue(documentMatchingPartOfWordIds.contains("document2")); + Assert.assertTrue(documentMatchingPartOfWordIds.contains("document3")); + } @Test -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit ccb5f72d7c83b70242ec671b350672f214ba1837 Merge: 135d795 c3c90ba Author: Yannick Martel <martel@©odelutin.com> Date: Mon Mar 2 18:24:21 2015 +0100 Merge branch 'develop' of https://git.codelutin.com/coselmar into develop coselmar-ui/src/main/webapp/css/coselmar.css | 3 +++ coselmar-ui/src/main/webapp/views/home.html | 2 +- coselmar-ui/src/main/webapp/views/questions/viewquestion.html | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm