Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Genesys Backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
45
Issues
45
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
Genesys Backend
Commits
b2f78498
Commit
b2f78498
authored
May 17, 2016
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added licensing headers and updated obsolete fragments
parent
127ef78e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
12 deletions
+76
-12
src/main/java/org/genesys2/server/service/ElasticSearchManagementService.java
...nesys2/server/service/ElasticSearchManagementService.java
+16
-0
src/main/java/org/genesys2/server/service/IndexAliasConstants.java
...java/org/genesys2/server/service/IndexAliasConstants.java
+16
-0
src/main/java/org/genesys2/server/service/impl/ElasticSearchManagementServiceImpl.java
...rver/service/impl/ElasticSearchManagementServiceImpl.java
+17
-1
src/main/java/org/genesys2/server/service/impl/ElasticsearchSearchServiceImpl.java
...2/server/service/impl/ElasticsearchSearchServiceImpl.java
+22
-6
src/main/java/org/genesys2/server/service/impl/FullTextSearchServiceImpl.java
...nesys2/server/service/impl/FullTextSearchServiceImpl.java
+5
-5
No files found.
src/main/java/org/genesys2/server/service/ElasticSearchManagementService.java
View file @
b2f78498
/**
* Copyright 2016 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package
org.genesys2.server.service
;
import
org.genesys2.server.service.impl.FilterHandler.AppliedFilters
;
...
...
src/main/java/org/genesys2/server/service/IndexAliasConstants.java
View file @
b2f78498
/**
* Copyright 2016 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package
org.genesys2.server.service
;
public
interface
IndexAliasConstants
{
...
...
src/main/java/org/genesys2/server/service/impl/ElasticSearchManagementServiceImpl.java
View file @
b2f78498
/**
* Copyright 2016 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package
org.genesys2.server.service.impl
;
import
com.hazelcast.core.ILock
;
...
...
@@ -129,7 +145,7 @@ public class ElasticSearchManagementServiceImpl implements ElasticSearchManageme
*/
@Override
public
void
regenerateIndexes
(
final
String
indexName
)
throws
ElasticsearchException
{
Class
clazz
=
null
;
Class
<?>
clazz
=
null
;
String
readAlias
=
null
;
String
writeAlias
=
null
;
if
(
IndexAliasConstants
.
INDEX_FULLTEXT
.
equals
(
indexName
))
{
...
...
src/main/java/org/genesys2/server/service/impl/ElasticsearchSearchServiceImpl.java
View file @
b2f78498
/**
* Copyright 2016 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package
org.genesys2.server.service.impl
;
import
java.sql.ResultSet
;
...
...
@@ -85,7 +101,7 @@ public class ElasticsearchSearchServiceImpl implements ElasticService, Initializ
@Override
public
Page
<
AccessionDetails
>
search
(
String
query
,
Pageable
pageable
)
throws
SearchException
{
SearchQuery
searchQuery
=
new
NativeSearchQueryBuilder
().
withIndices
(
IndexAliasConstants
.
INDEXALIAS_PASSPORT_READ
).
withTypes
(
IndexAliasConstants
.
PASSPORT_TYPE
)
.
withQuery
(
org
.
elasticsearch
.
index
.
query
.
QueryBuilders
.
queryString
(
query
).
defaultOperator
(
Operator
.
AND
)).
withPageable
(
pageable
).
build
();
.
withQuery
(
org
.
elasticsearch
.
index
.
query
.
QueryBuilders
.
queryString
Query
(
query
).
defaultOperator
(
Operator
.
AND
)).
withPageable
(
pageable
).
build
();
try
{
Page
<
AccessionDetails
>
sampleEntities
=
elasticsearchTemplate
.
queryForPage
(
searchQuery
,
AccessionDetails
.
class
);
...
...
@@ -98,7 +114,7 @@ public class ElasticsearchSearchServiceImpl implements ElasticService, Initializ
@Override
public
List
<
String
>
autocompleteSearch
(
String
query
)
throws
SearchException
{
SearchQuery
searchQuery
=
new
NativeSearchQueryBuilder
().
withIndices
(
IndexAliasConstants
.
INDEXALIAS_PASSPORT_READ
).
withTypes
(
IndexAliasConstants
.
PASSPORT_TYPE
)
.
withQuery
(
org
.
elasticsearch
.
index
.
query
.
QueryBuilders
.
queryString
(
"acceNumb:("
+
query
+
"*)"
).
defaultOperator
(
Operator
.
AND
))
.
withQuery
(
org
.
elasticsearch
.
index
.
query
.
QueryBuilders
.
queryString
Query
(
"acceNumb:("
+
query
+
"*)"
).
defaultOperator
(
Operator
.
AND
))
.
withSort
(
SortBuilders
.
fieldSort
(
FilterConstants
.
ACCENUMB
).
order
(
SortOrder
.
ASC
)).
withPageable
(
new
PageRequest
(
0
,
10
)).
build
();
try
{
...
...
@@ -243,9 +259,9 @@ public class ElasticsearchSearchServiceImpl implements ElasticService, Initializ
if
(
FilterConstants
.
ALIAS
.
equals
(
key
))
{
// Nested
orFilter
.
add
(
FilterBuilders
.
nestedFilter
(
"aliases"
,
QueryBuilders
.
queryString
(
"aliases.name"
+
":("
+
sb
.
toString
()
+
")"
)));
orFilter
.
add
(
FilterBuilders
.
nestedFilter
(
"aliases"
,
QueryBuilders
.
queryString
Query
(
"aliases.name"
+
":("
+
sb
.
toString
()
+
")"
)));
}
else
{
orFilter
.
add
(
FilterBuilders
.
queryFilter
(
QueryBuilders
.
queryString
(
key
+
":("
+
sb
.
toString
()
+
")"
)));
orFilter
.
add
(
FilterBuilders
.
queryFilter
(
QueryBuilders
.
queryString
Query
(
key
+
":("
+
sb
.
toString
()
+
")"
)));
}
}
else
{
// terms
...
...
@@ -280,9 +296,9 @@ public class ElasticsearchSearchServiceImpl implements ElasticService, Initializ
if
(
genesysFilter
.
isAnalyzed
())
{
if
(
FilterConstants
.
ALIAS
.
equals
(
key
))
{
orFilter
.
add
(
FilterBuilders
.
nestedFilter
(
"aliases"
,
QueryBuilders
.
queryString
(
"aliases.name"
+
":"
+
startsWith
.
getStartsWith
()
+
"*"
)));
QueryBuilders
.
queryString
Query
(
"aliases.name"
+
":"
+
startsWith
.
getStartsWith
()
+
"*"
)));
}
else
{
orFilter
.
add
(
FilterBuilders
.
queryFilter
(
QueryBuilders
.
queryString
(
key
+
":"
+
startsWith
.
getStartsWith
()
+
"*"
)));
orFilter
.
add
(
FilterBuilders
.
queryFilter
(
QueryBuilders
.
queryString
Query
(
key
+
":"
+
startsWith
.
getStartsWith
()
+
"*"
)));
}
}
else
{
orFilter
.
add
(
FilterBuilders
.
prefixFilter
(
key
,
startsWith
.
getStartsWith
()));
...
...
src/main/java/org/genesys2/server/service/impl/FullTextSearchServiceImpl.java
View file @
b2f78498
...
...
@@ -18,7 +18,7 @@ package org.genesys2.server.service.impl;
import
static
org
.
elasticsearch
.
index
.
query
.
QueryBuilders
.
boolQuery
;
import
static
org
.
elasticsearch
.
index
.
query
.
QueryBuilders
.
functionScoreQuery
;
import
static
org
.
elasticsearch
.
index
.
query
.
QueryBuilders
.
matchQuery
;
import
static
org
.
elasticsearch
.
index
.
query
.
QueryBuilders
.
queryString
;
import
static
org
.
elasticsearch
.
index
.
query
.
QueryBuilders
.
queryString
Query
;
import
static
org
.
elasticsearch
.
index
.
query
.
functionscore
.
ScoreFunctionBuilders
.
fieldValueFactorFunction
;
import
java.util.ArrayList
;
...
...
@@ -144,7 +144,7 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
.
withQuery
(
functionScoreQuery
(
boolQuery
().
must
(
matchQuery
(
CLASSPK_SHORTNAME
,
classPK
.
getShortName
())).
must
(
queryString
(
query
).
defaultOperator
(
QueryStringQueryBuilder
.
Operator
.
AND
))).
add
(
queryString
Query
(
query
).
defaultOperator
(
QueryStringQueryBuilder
.
Operator
.
AND
))).
add
(
fieldValueFactorFunction
(
"score"
).
factor
(
1.0f
))).
withPageable
(
pageable
).
build
();
try
{
...
...
@@ -156,7 +156,7 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
}
private
Page
<?>
toEntities
(
FacetedPage
<
FullTextDocument
>
fulltextResults
,
Pageable
pageable
)
{
List
content
=
new
ArrayList
(
fulltextResults
.
getSize
());
List
<
Object
>
content
=
new
ArrayList
<>
(
fulltextResults
.
getSize
());
for
(
FullTextDocument
document
:
fulltextResults
.
getContent
())
{
content
.
add
(
toEntity
(
document
.
getClassPK
().
getClassName
(),
document
.
getId
()));
}
...
...
@@ -185,7 +185,7 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
}
SearchQuery
searchQuery
;
Class
clazz
;
Class
<?>
clazz
;
if
(
section
.
equals
(
ACCESSION_SECTION
))
{
throw
new
UnsupportedOperationException
(
"Use ElasticsearchServiceImpl for accession search"
);
...
...
@@ -195,7 +195,7 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
.
withQuery
(
functionScoreQuery
(
boolQuery
().
must
(
matchQuery
(
CLASSPK_SHORTNAME
,
section
)).
must
(
queryString
(
query
).
defaultOperator
(
QueryStringQueryBuilder
.
Operator
.
AND
))).
add
(
queryString
Query
(
query
).
defaultOperator
(
QueryStringQueryBuilder
.
Operator
.
AND
))).
add
(
fieldValueFactorFunction
(
"score"
).
factor
(
1.0f
))).
withPageable
(
pageable
).
build
();
clazz
=
FullTextDocument
.
class
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment