Showing preview only (2,205K chars total). Download the full file or copy to clipboard to get everything.
Repository: graphaware/graph-aided-search
Branch: master
Commit: b66a5bad4918
Files: 74
Total size: 2.1 MB
Directory structure:
gitextract_nj6_eb0u/
├── .gitignore
├── .travis.yml
├── README.md
├── gpl.txt
├── pom.xml
└── src/
├── main/
│ ├── assemblies/
│ │ └── plugin.xml
│ ├── java/
│ │ └── com/
│ │ └── graphaware/
│ │ └── es/
│ │ └── gas/
│ │ ├── GraphAidedSearch.java
│ │ ├── GraphAidedSearchFilter.java
│ │ ├── GraphAidedSearchModule.java
│ │ ├── GraphAidedSearchPlugin.java
│ │ ├── annotation/
│ │ │ ├── SearchBooster.java
│ │ │ └── SearchFilter.java
│ │ ├── booster/
│ │ │ ├── SearchResultBooster.java
│ │ │ ├── SearchResultCypherBooster.java
│ │ │ ├── SearchResultExternalBooster.java
│ │ │ └── SearchResultNeo4jBooster.java
│ │ ├── cypher/
│ │ │ ├── CypherBoltHttpEndPoint.java
│ │ │ ├── CypherEndPoint.java
│ │ │ ├── CypherEndPointBuilder.java
│ │ │ ├── CypherHttpEndPoint.java
│ │ │ ├── CypherResult.java
│ │ │ ├── CypherSettingsReader.java
│ │ │ └── ResultRow.java
│ │ ├── domain/
│ │ │ ├── ClauseConstants.java
│ │ │ ├── ExternalResult.java
│ │ │ └── IndexInfo.java
│ │ ├── filter/
│ │ │ ├── SearchResultCypherFilter.java
│ │ │ └── SearchResultFilter.java
│ │ ├── modifier/
│ │ │ ├── PrivilegedSearchResultModifier.java
│ │ │ └── SearchResultModifier.java
│ │ ├── util/
│ │ │ ├── Instantiator.java
│ │ │ ├── NumberUtil.java
│ │ │ ├── ParamUtil.java
│ │ │ ├── PluginClassLoader.java
│ │ │ └── UrlUtil.java
│ │ └── wrap/
│ │ ├── ActionListenerWrapper.java
│ │ ├── CannotWrapException.java
│ │ ├── GraphAidedSearchActionListenerWrapper.java
│ │ └── WrappingActionListener.java
│ └── plugin-metadata/
│ ├── plugin-descriptor.properties
│ └── plugin-security.policy
└── test/
├── java/
│ └── com/
│ └── graphaware/
│ └── es/
│ └── gas/
│ ├── EmbeddedGraphDatabaseServerTest.java
│ ├── GraphAidedSearchFilterTest.java
│ ├── GraphAidedSearchIntegrationBoltTest.java
│ ├── GraphAidedSearchIntegrationTest.java
│ ├── GraphAidedSearchNeo4jIntegrationTest.java
│ ├── GraphAidedSearchTest.java
│ ├── JestMsgResult.java
│ ├── MockServerTest.java
│ ├── booster/
│ │ ├── GraphBoosterTest.java
│ │ ├── SearchResultCypherBoltBoosterTest.java
│ │ ├── SearchResultCypherBoosterTest.java
│ │ └── SearchResultNeo4jBoosterTest.java
│ ├── domain/
│ │ ├── CypherEndpointBoltTest.java
│ │ ├── CypherEndpointTest.java
│ │ ├── CypherEndpointUnitTest.java
│ │ ├── ExternalResultTest.java
│ │ ├── ExternalResultUnitTest.java
│ │ └── TestIndexInfo.java
│ ├── filter/
│ │ ├── GraphFilterTest.java
│ │ └── SearchResultCypherFilterTest.java
│ ├── stubs/
│ │ ├── CypherSearchResultTestBooster.java
│ │ ├── CypherSearchResultTestFilter.java
│ │ └── SearchResultTestBooster.java
│ └── util/
│ ├── ClauseConstantsTest.java
│ ├── NumberUtilTest.java
│ ├── TestHttpClient.java
│ └── UrlUtilTest.java
└── resources/
├── demo-data-reduced.cyp
├── demo-data.cyp
├── graphgen-test-data.cyp
├── neo4j-elasticsearch-reco.properties
├── neo4j-elasticsearch.properties
└── neo4j-server-es.properties
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# Created by https://www.gitignore.io
### Project ###
data/
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
*.iml
## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:
# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries
# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml
# Gradle:
# .idea/gradle.xml
# .idea/libraries
# Mongo Explorer plugin:
# .idea/mongoSettings.xml
## File-based project format:
*.ipr
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
### OSX ###
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
### Java ###
*.class
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/extlib/
/neo4j-home/
nb-configuration.xml
/data/
.classpath
.project
.settings/
neo4jextlib
================================================
FILE: .travis.yml
================================================
language: java
before_install:
- sudo apt-get update > /dev/null
jdk:
- oraclejdk8
- oraclejdk7
branches:
only:
- master
- 2.2
after_success:
- echo "<settings><servers><server><id>ossrh</id><username>\${env.OSSRH_USER}</username><password>\${env.OSSRH_PASS}</password></server></servers></settings>" > ~/settings.xml
- mvn deploy --settings ~/settings.xml
================================================
FILE: README.md
================================================
# GraphAware Graph-Aided Search - RETIRED
## GraphAware Graph-Aided Search Has Been Retired
As of May 2021, this [repository has been retired](https://graphaware.com/framework/2021/05/06/from-graphaware-framework-to-graphaware-hume.html).
## ElasticSearch Plugin providing integration with Neo4j
GraphAware Graph-Aided Search is an enterprise-grade bi-directional integration between Neo4j and Elasticsearch. It consists
of two independent modules plus test suites. Both modules can be used independently or together to achieve full integration.
The [first module](https://github.com/graphaware/neo4j-to-elasticsearch) is a plugin for Neo4j (more precisely, a [GraphAware Transaction-Driven Runtime Module](https://github.com/graphaware/neo4j-framework/tree/master/runtime#graphaware-runtime)),
which can be configured to transparently and asynchronously replicate data from Neo4j to ElasticSearch.
The second module (this module) is a plugin for Elasticsearch that can query the Neo4j graph database during a search query
to enrich the result (boost the score) by results that are more efficiently calculated in a graph database, e.g. recommendations.
Both modules are now open-source production-ready for everyone. They are also officially supported by GraphAware for <a href="http://graphaware.com/enterprise/" target="_blank">GraphAware Enterprise</a> subscribers.
## Feature Overview: Graph-Aided Search
This module is a plugin for Elasticsearch that enables users to improve search results by boosting or filtering them using data stored in the Neo4j graph database.
After performing a search in Elasticsearch, just before returning the results to the user, this plugin requests additional information from Neo4j via its REST API in order to boost or filter the results.
Two main features are exposed by the plugin:
* **_Result Boosting_**: This feature allows changing the scores of the results. The score can be changed in different ways: mixing graph score with Elasticsearch score or replacing it entirely are just two examples.
It is possible to customize this behaviour with different formulas, rewriting some methods of the Graph-Aided Search Booster.
Usage examples include boosting (i) based on interest prediction (recommendations), (ii) based on friends' interests/likes, (iii) all use cases that are a good fit for Neo4j
* **_Result Filtering_**: This feature allows filtering, thus removing documents from the results list. By providing a Cypher query, it is possible to return to the user only documents with IDs matching the results of the Cypher query.
Detailed workflow:
1. Intercept and parse any "Search query" and try to find the `GraphAidedSearch` extension parameter;
2. Process the query extension identifying the type of the extension (boosting or a filter), and instantiate the related class;
3. Perform the operation required to boost or filter by calling the Neo4j REST API (or a Neo4j extension like [Graphaware Recommendation Engine](https://github.com/graphaware/neo4j-reco), passing all necessary information,
e.g. Cypher query, target user, etc...;
4. Return the filtered/boosted result set back to the user;

---
## Usage: Installation
### Install Graph-Aided Search Binary
#### Elasticsearch 2.2.2:
```bash
$ $ES_HOME/bin/plugin install com.graphaware.es/graph-aided-search/2.2.2.0
```
#### Elasticsearch 2.3.1:
```bash
$ $ES_HOME/bin/plugin install com.graphaware.es/graph-aided-search/2.3.2.0
```
### Build from source
```bash
$ git clone git@github.com:graphaware/graph-aided-search.git
$ mvn clean package
$ $ES_HOME/bin/plugin install file:///path/to/project/graph-aided-search/target/releases/graph-aided-search-2.X.X.0.zip
```
Start elasticsearch
### Configuration
Then configure indexes with the url of Neo4j. This can be done in two ways. First:
```bash
$ curl -XPUT http://localhost:9200/indexname/_settings?index.gas.neo4j.hostname=http://localhost:7474
$ curl -XPUT http://localhost:9200/indexname/_settings?index.gas.enable=true
```
> **indexname** as your index name.
e.g.
curl -XPUT http://localhost:9200/neo4j-index-node/_settings?index.gas.enable=true
If the Neo4j Rest Api is protected by Basic Authentication confire username and password for neo4j in the following way:
```bash
$ curl -XPUT http://localhost:9200/indexname/_settings?index.gas.neo4j.user=neo4j
$ curl -XPUT http://localhost:9200/indexname/_settings?index.gas.neo4j.password=password
```
If the neo4j server supports bolt it can be enable and managed using the following configuration
```bash
$ curl -XPUT http://localhost:9200/indexname/_settings?index.gas.neo4j.boltHostname=bolt://localhost:7687
$ curl -XPUT http://localhost:9200/indexname/_settings?index.gas.neo4j.bolt.secure=false (default is true)
```
Since bolt is still not a stabel release, the default protocol is http, to enable it add the following line in the booster or filter configuration:
```json
"protocol": "bolt"
```
Second, you can use also template to configure settings in the index:
```json
curl -XPOST http://localhost:9200/_template/template_gas -d \
'{
"template": "*",
"settings": {
"index.gas.neo4j.hostname": "http://localhost:7474",
"index.gas.neo4j.boltHostname": "bolt://localhost:7687",
"index.gas.enable": true,
"index.gas.neo4j.user": "neo4j",
"index.gas.neo4j.password": "password"
}
}'
```
### Disable Plugin
```bash
$ curl -XPUT http://localhost:9200/indexname/_settings?index.gas.enable=false
```
Queries will continue to work even with Graph-Aided-Search-specific elements, e.g. "gas-boost" and "gas-filter".
## Usage: Search Phase
The integration with a pre-existing search query is seamless, since the plugin only requires the addition of new elements into the query.
### Booster example
Boosters allow to change the score by an external score source. This could be a `recommender`, a Cypher query, or any custom booster provider.
A simple Elasticsearch query could have the following structure:
```bash
curl -X POST http://localhost:9200/neo4j-index/Movie/_search -d '{
"query" : {
"match_all" : {}
}';
```
In this case all the Elasticsearch result hits will have a relevancy score value of `1`. If you would like to boost these results according to user interest computed by Graphaware Recommendation Plugin on top of
Neo4j, you would change the query in the following way.
```bash
curl -X POST http://localhost:9200/neo4j-index/Movie/_search -d '{
"query" : {
"match_all" : {}
},
"gas-booster" :{
"name": "SearchResultNeo4jBooster",
"target": "2",
"maxResultSize": 10,
"keyProperty": "objectId",
"neo4j.endpoint": "/graphaware/recommendation/movie/filter/"
}
}';
```
The **_gas-booster_** clause identifies the type of operation, in this case it defines a boost operation.
The **_name_** parameter is mandatory and allows to specify the Booster class. The remaining parameters depend on the type of the booster.
In the following paragraph the available boosters are described.
#### SearchResultNeo4jBooster
This booster uses Neo4j through custom REST APIs available as plugins for the database. In this case, the _name_ value must be set to `SearchResultNeo4jBooster`.
The following parameters are available for this booster:
* **target**: (Mandatory) This parameter contains the identifier of the target for which the boosting values are computed.
Since the boosting is customized according to a target, this parameter is mandatory and allows getting different results for different target (typically a user).
* **maxResultSize**: (Default is set to the max result windows size of elasticsearch, defined by the parameter index.max_result_window)
When search query is changed before submitting it to elasticsearch engine, the value of "size" for the results returned is changed according to this parameter.
This is necessary since once the boosting function is applied, the order may change. Some of the results that wouldn't "make it" may be boosted and fall into the "size" window.
* **keyProperty**: (Default value is `uuid`) the id of each document in the search results must match some property value of the nodes in the graph.
In order to avoid ambiguities in the results, this property must identify a single node. Using <a href="https://github.com/graphaware/neo4j-uuid" target="_blank">GraphAware UUID</a> with Neo4j is recommended for this purpose.
* **operator**: (Default is multiply [*]) It specifies how to combine the Elasticsearch score with the score provided by Neo4j.
Available operators are: * (multiply), + (sum), - (substract), / (divide), replace (replace score).
* **neo4j.endpoint**: (Default /graphaware/recommendation/filter) It defines the endpoint to which the request is submitted in order to get a boosting.
It is added to the Neo4j host value defined for the index.
Information about the list of IDs that should be boosted as well as the target is passed to the API running atop Neo4j. The REST API should expose a POST endpoint that accepts the following parameters:
* **target** (url parameter): This is the value of target defined above and it is used to identify the user or item for which the score will be computed from the recommender;
* **limit**: This value can be used to limit the number of results provided be the REST API;
* **from**: In order to support pagination this value allows to skip a number of results;
* **keyProperty**: Specify the property on the nodes used to identify the nodes. Such property will be used to filter the results, according to the lists of "ids";
* **ids**: Comma-separated list of node identifiers that must be evaluated and then returned;
Example Call:
```
http://localhost:7474/graphaware/recommendation/movie/filter/2
Parameters:
limit=2147483647&from=0&keyProperty=objectId&ids=99,166,486,478,270,172,73,84,351,120
```
This component supposes that the results are a json array with the following structure.
```json
[
{
"nodeId": 1212,
"objectId": "270",
"score": 3
},
{
"nodeId": 1041,
"objectId": "99",
"score": 1
},
{
"nodeId": 1420,
"objectId": "478",
"score": 1
},
{
"nodeId": 1428,
"objectId": "486",
"score": 1
}
]
```
#### SearchResultCypherBooster
This booster uses Neo4j through custom REST APIs available as plugins for the database. In this case the _name_ value must be set to `SearchResultCypherBooster`.
The following parameters are available for this booster:
* **query**: (Mandatory) This parameter contains the query to submit to the Neo4j instance.
* **scoreName**: (Default value is "score") The name of the returned value that is used as scoring function.
* **identifier**: (Default value is "id") The name of the returned value that is used for matching IDs.
* **maxResultSize**: (Default is set to the max result windows size of elasticsearch, defined by the parameter index.max_result_window)
When search query is changed before submitting it to elasticsearch engine, the value of "size" for the results returned is changed according to this parameter.
This is necessary since once the boosting function is applied, the order may change. Some of the results that wouldn't "make it" may be boosted and fall into the "size" window.
* **operator**: (Default is multiply [*]) It specifies how to combine the Elasticsearch score with the score provided by Neo4j.
Available operators are: * (multiply), + (sum), - (substract), / (divide), replace (replace score).
The Elasticsearch result hits ids are passed as Cypher query parameter as a `List` of strings named `items`.
Example Use:
```
curl -X POST http://localhost:9200/neo4j-index/Movie/_search -d '{
"query" : {
"match_all" : {}
},
"gas-booster" :{
"name": "SearchResultCypherBooster",
"query": "MATCH (input:User) WHERE id(input) = 2
MATCH p=(input)-[r:RATED]->(movie)<-[r2:RATED]-(other)
WITH other, collect(p) as paths
WITH other, reduce(x=0, p in paths | x + reduce(i=0, r in rels(p) | i+r.rating)) as score
WITH other, score
ORDER BY score DESC
MATCH (other)-[:RATED]->(reco)
RETURN reco.objectId as id, score
LIMIT 500",
"maxResultSize": 1000,
"scoreName": "score",
"identifier": "id"
}
}';
```
### Filter Example
Filters allow to filter the results using information stored in the graph. For example, you can filter movies based on what the user's friends have seen.
If you would like to filter results according to a user's friends evaluation, it is possible to change the Elasticsearch query as follows:
```
curl -X POST http://localhost:9200/neo4j-index/Movie/_search -d '{
"query" : {
"match_all" : {}
},
"gas-filter" :{
"name": "SearchResultCypherFilter",
"query": "MATCH (input:User) WHERE id(input) = 2
MATCH (input)-[f:FRIEND_OF]->(friend)-[r:RATED]->(movie)
WHERE r.rate > 3
RETURN movie.uuid as id",
"exclude": false
}
}';
```
The **_gas-filter_** clause identifies the type of the operation; in this case a filter operation.
The **_name_** parameter is mandatory and allows to specify the Filter class. The remaining parameters depends on the type of filter.
In the following paragraph the available filters are described.
#### SearchResultCypherFilter
This filter allows to filter results using a Cypher query on Neo4j. In this case the _name_ value must be set to `SearchResultCypherFilter`.
The following parameters are available for this filter:
* **query**: (Mandatory) This parameter contains the query to submit to the Neo4j instance.
* **maxResultSize**: (Default is set to the max result windows size of elasticsearch, defined by the parameter index.max_result_window)
When search query is changed before submitting it to elasticsearch engine, the value of "size" for the results returned is changed according to this parameter.
This is necessary since once the filtering function is applied, some of the results that wouldn't "make it" may fall into the "size" window.
* **exclude**: (Default true) This parameter allows to define the behaviour of the Filter.
If set to true (default), it will filter out the Neo4j results from the results provided by Elasticsearch. If set to false, it will
keep the intersection of Neo4j and Elasticsearch results, i.e. exclude everything that has not been returned by Neo4j.
## Customize the plugin
The plugin allows to implement custom boosters and filters. In order to implement a booster, `SearchResultBooster` must be implemented
and it needs to have the following annotation:
```
@SearchBooster(name = "MyCustomBooster")
```
Moreover, it should be in the package `com.graphaware.es.gas`.
In order to implement a filter, `SearchResultFilter` must be implemented and it needs to have the following annotation:
```
@SearchFilter(name = "MyCustomFilter")
```
Also in this case, it should be in the package `com.graphaware.es.gas`.
## Version Matrix
The following version are currently supported
| Version (this project) | Elasticsearch |
|:---------:|:-------------:|
| master | 2.4.4 |
| 2.3.2.2 | 2.3.2 |
| 2.3.1.0 | 2.3.1 |
| 2.2.2.0 | 2.2.2 |
### Issues/Questions
Please file an [issue](https://github.com/graphaware/graph-aided-search/issues "issue").
License
-------
Copyright (c) 2016 GraphAware
GraphAware is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, see <http://www.gnu.org/licenses/>.
================================================
FILE: gpl.txt
================================================
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
================================================
FILE: pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2013-2016 GraphAware
~
~ This file is part of the GraphAware Framework.
~
~ GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
~ the GNU General Public License as published by the Free Software Foundation, either
~ version 3 of the License, or (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~ See the GNU General Public License for more details. You should have received a copy of
~ the GNU General Public License along with this program. If not, see
~ <http://www.gnu.org/licenses />.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.graphaware.es</groupId>
<artifactId>graph-aided-search</artifactId>
<version>2.4.4.4-SNAPSHOT</version>
<properties>
<java.version>1.7</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<elasticsearch.version>2.4.4</elasticsearch.version>
<bolt.version>1.1.0-M04</bolt.version>
<elasticsearch.plugin.classname>com.graphaware.es.gas.GraphAidedSearchPlugin</elasticsearch.plugin.classname>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<name>Graph-Aided Search</name>
<description>GraphAware Elasticsearch Plugin for Integration with Neo4j</description>
<url>http://graphaware.com</url>
<licenses>
<license>
<name>GNU General Public License, version 3</name>
<url>http://www.gnu.org/licenses/gpl-3.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<organization>
<name>Graph Aware Limited</name>
<url>http://graphaware.com</url>
</organization>
<scm>
<connection>scm:git:git@github.com:graphaware/graph-aided-search.git</connection>
<developerConnection>scm:git:git@github.com:graphaware/graph-aided-search.git</developerConnection>
<url>git@github.com:graphaware/graph-aided-search.git</url>
<tag>HEAD</tag>
</scm>
<profiles>
<profile>
<id>release</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>doclint-java8-disable</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>intellij-javadoc-fix</id>
<build>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<configuration>
<javadocExecutable>${java.home}/../bin/javadoc</javadocExecutable>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<developers>
<developer>
<id>alenegro</id>
<name>Alessandro Negro</name>
<email>alessandro@graphaware.com</email>
</developer>
<developer>
<id>ikwattro</id>
<name>Christophe Willemsen</name>
<email>christophe@graphaware.com</email>
</developer>
<developer>
<id>bachmanm</id>
<name>Michal Bachman</name>
<email>graph-aided-search@graphaware.com</email>
</developer>
</developers>
<ciManagement>
<url>https://travis-ci.org/graphaware/graph-aided-search</url>
<system>Travis CI</system>
</ciManagement>
<inceptionYear>2015</inceptionYear>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/graphaware/graph-aided-search/issues</url>
</issueManagement>
<dependencies>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${elasticsearch.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.9</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>${bolt.version}</version>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>org.codelibs</groupId>
<artifactId>elasticsearch-cluster-runner</artifactId>
<version>2.3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.searchbox</groupId>
<artifactId>jest</artifactId>
<version>2.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.graphaware.integration.neo4j</groupId>
<artifactId>neo4j-tests-integration</artifactId>
<version>3.0.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.3.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-netty</artifactId>
<version>3.10.4</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>release</releaseProfiles>
<goals>deploy</goals>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<outputDirectory>${project.build.directory}/releases/</outputDirectory>
<descriptors>
<descriptor>${basedir}/src/main/assemblies/plugin.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<retryFailedDeploymentCount>10</retryFailedDeploymentCount>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<configuration>
<aggregate>true</aggregate>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
<execution>
<id>aggregate</id>
<goals>
<goal>aggregate</goal>
</goals>
<phase>site</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-model</id>
<phase>compile</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<artifactItems>
<artifactItem>
<groupId>com.graphaware.integration.neo4j</groupId>
<artifactId>neo4j-tests-integration</artifactId>
<version>3.0.6.1</version>
<classifier>shaded</classifier>
<overWrite>true</overWrite>
</artifactItem>
<artifactItem>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<overWrite>false</overWrite>
</artifactItem>
<artifactItem>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.19</version>
</artifactItem>
</artifactItems>
<outputDirectory>${project.basedir}/neo4jextlib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<filesets>
<fileset>
<directory>${project.basedir}/neo4jextlib</directory>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<argLine>-Xmx2048m -XX:MaxPermSize=512m</argLine>
<systemPropertyVariables>
<classpath>${project.basedir}/neo4jextlib</classpath>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>
================================================
FILE: src/main/assemblies/plugin.xml
================================================
<?xml version="1.0"?>
<!--
~ Copyright (c) 2013-2016 GraphAware
~
~ This file is part of the GraphAware Framework.
~
~ GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
~ the GNU General Public License as published by the Free Software Foundation, either
~ version 3 of the License, or (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~ See the GNU General Public License for more details. You should have received a copy of
~ the GNU General Public License along with this program. If not, see
~ <http://www.gnu.org/licenses/>.
-->
<assembly>
<id>plugin</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<files>
<file>
<source>${basedir}/src/main/plugin-metadata/plugin-descriptor.properties</source>
<outputDirectory></outputDirectory>
<filtered>true</filtered>
</file>
<file>
<source>${basedir}/src/main/plugin-metadata/plugin-security.policy</source>
<outputDirectory></outputDirectory>
<filtered>true</filtered>
</file>
</files>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<useTransitiveFiltering>true</useTransitiveFiltering>
<excludes>
<exclude>com.google.guava:guava</exclude>
</excludes>
</dependencySet>
</dependencySets>
</assembly>
================================================
FILE: src/main/java/com/graphaware/es/gas/GraphAidedSearch.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas;
import com.graphaware.es.gas.wrap.ActionListenerWrapper;
import com.graphaware.es.gas.wrap.GraphAidedSearchActionListenerWrapper;
import org.elasticsearch.action.support.ActionFilter;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.common.component.AbstractLifecycleComponent;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.threadpool.ThreadPool;
public class GraphAidedSearch extends AbstractLifecycleComponent<GraphAidedSearch> {
private final ActionListenerWrapper<?> wrapper;
private final ActionFilters filters;
@Inject
public GraphAidedSearch(final Settings settings, final Client client, final ClusterService clusterService, final ScriptService scriptService, final ThreadPool threadPool, final ActionFilters filters) {
super(settings);
this.filters = filters;
this.wrapper = new GraphAidedSearchActionListenerWrapper(settings, clusterService, client);
initializeFilters();
}
private void initializeFilters() {
for (final ActionFilter filter : filters.filters()) {
if (filter instanceof GraphAidedSearchFilter) {
((GraphAidedSearchFilter) filter).setWrapper(wrapper);
if (logger.isDebugEnabled()) {
logger.debug("Set GraphAidedSearch to " + filter);
}
}
}
}
@Override
protected void doStart() {
}
@Override
protected void doStop() {
}
@Override
protected void doClose() {
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/GraphAidedSearchFilter.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas;
import com.graphaware.es.gas.wrap.ActionListenerWrapper;
import com.graphaware.es.gas.wrap.CannotWrapException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.search.SearchAction;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.support.ActionFilter;
import org.elasticsearch.action.support.ActionFilterChain;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.tasks.Task;
public class GraphAidedSearchFilter extends AbstractComponent implements ActionFilter {
private static final int DEFAULT_FILTER_ORDER = 10;
private static final String FILTER_ORDER_KEY_NAME = "indices.graphaware.filter.order";
protected final ESLogger logger;
private final int order;
private ActionListenerWrapper<?> wrapper;
@Inject
public GraphAidedSearchFilter(final Settings settings) {
super(settings);
logger = Loggers.getLogger(GraphAidedSearchFilter.class.getName(), settings);
order = settings.getAsInt(FILTER_ORDER_KEY_NAME, DEFAULT_FILTER_ORDER);
}
public void setWrapper(ActionListenerWrapper<?> wrapper) {
this.wrapper = wrapper;
}
@Override
public int order() {
return order;
}
@Override
public void apply(Task task, String action, ActionRequest request, ActionListener listener, ActionFilterChain chain) {
if (SearchAction.INSTANCE.name().equals(action)) {
try {
listener = wrapper.wrap((SearchRequest) request, listener);
} catch (CannotWrapException e) {
//that's OK, will use the original unwrapped one and perform no Graph-Aided Search
}
}
chain.proceed(task, action, request, listener);
}
@Override
public void apply(final String action, final ActionResponse response, final ActionListener listener, final ActionFilterChain chain) {
chain.proceed(action, response, listener);
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/GraphAidedSearchModule.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas;
import org.elasticsearch.common.inject.AbstractModule;
public class GraphAidedSearchModule extends AbstractModule {
@Override
protected void configure() {
bind(GraphAidedSearch.class).asEagerSingleton();
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/GraphAidedSearchPlugin.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas;
import org.elasticsearch.action.ActionModule;
import org.elasticsearch.cluster.ClusterModule;
import org.elasticsearch.cluster.settings.Validator;
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.plugins.Plugin;
import java.util.Collection;
import java.util.Collections;
import static com.graphaware.es.gas.wrap.GraphAidedSearchActionListenerWrapper.*;
public class GraphAidedSearchPlugin extends Plugin {
@Override
public String name() {
return "GraphAidedSearchPlugin";
}
@Override
public String description() {
return "GraphAware Graph-Aided Search Plugin for Neo4j.";
}
public void onModule(final ActionModule module) {
module.registerFilter(GraphAidedSearchFilter.class);
}
public void onModule(final ClusterModule module) {
module.registerIndexDynamicSetting(INDEX_GA_ES_NEO4J_ENABLED, Validator.BOOLEAN);
module.registerIndexDynamicSetting(INDEX_GA_ES_NEO4J_HOST, Validator.EMPTY);
module.registerIndexDynamicSetting(INDEX_GA_ES_NEO4J_USER, Validator.EMPTY);
module.registerIndexDynamicSetting(INDEX_GA_ES_NEO4J_PWD, Validator.EMPTY);
}
@Override
public Collection<Module> nodeModules() {
return Collections.<Module>singleton(new GraphAidedSearchModule());
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/annotation/SearchBooster.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface SearchBooster {
String name();
}
================================================
FILE: src/main/java/com/graphaware/es/gas/annotation/SearchFilter.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface SearchFilter {
String name();
}
================================================
FILE: src/main/java/com/graphaware/es/gas/booster/SearchResultBooster.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.booster;
import com.graphaware.es.gas.modifier.SearchResultModifier;
public interface SearchResultBooster extends SearchResultModifier {
}
================================================
FILE: src/main/java/com/graphaware/es/gas/booster/SearchResultCypherBooster.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.booster;
import com.graphaware.es.gas.annotation.SearchBooster;
import com.graphaware.es.gas.cypher.CypherEndPoint;
import com.graphaware.es.gas.cypher.CypherEndPointBuilder;
import com.graphaware.es.gas.cypher.CypherResult;
import com.graphaware.es.gas.cypher.ResultRow;
import com.graphaware.es.gas.domain.ExternalResult;
import com.graphaware.es.gas.domain.IndexInfo;
import com.graphaware.es.gas.util.NumberUtil;
import com.graphaware.es.gas.util.UrlUtil;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import static com.graphaware.es.gas.domain.ClauseConstants.*;
import static com.graphaware.es.gas.util.ParamUtil.extractParameter;
@SearchBooster(name = "SearchResultCypherBooster")
public class SearchResultCypherBooster extends SearchResultExternalBooster {
private final ESLogger logger;
private CypherEndPoint cypherEndPoint;
private String cypherQuery;
private String scoreResultName;
private String idResultName;
public SearchResultCypherBooster(Settings settings, IndexInfo indexInfo) {
super(settings, indexInfo);
this.logger = Loggers.getLogger(IndexInfo.INDEX_LOGGER_NAME, settings);
}
@Override
protected void extendedParseRequest(Map<String, String> extParams) {
cypherQuery = extractParameter(QUERY, extParams);
scoreResultName = extractParameter(SCORE_NAME, extParams, DEFAULT_SCORE_RESULT_NAME);
idResultName = extractParameter(IDENTIFIER, extParams, DEFAULT_ID_RESULT_NAME);
String protocol = extParams.containsKey(PROTOCOL) ? String.valueOf(extParams.get(PROTOCOL)) : DEFAULT_PROTOCOL;
cypherEndPoint = createCypherEndPoint(protocol, getSettings());
}
@Override
protected Map<String, ExternalResult> externalDoReorder(Set<String> keySet) {
logger.debug("Query cypher for: " + keySet);
return getExternalResults(keySet);
}
protected Map<String, ExternalResult> getExternalResults(Set<String> keySet) {
CypherResult externalResult = cypherEndPoint.executeCypher(cypherQuery, getParameters(keySet));
Map<String, ExternalResult> results = new HashMap<>();
for (ResultRow resultRow : externalResult.getRows()) {
checkResultRow(resultRow);
results.put(String.valueOf(resultRow.get(getIdResultName())), new ExternalResult(String.valueOf(resultRow.get(getIdResultName())), NumberUtil.getFloat(resultRow.get(getScoreResultName()))));
}
return results;
}
public HashMap<String, Object> getParameters(Set<String> resultKeySet) {
HashMap<String, Object> parameters = new HashMap<>();
parameters.put("ids", resultKeySet);
return parameters;
}
public String getEndpoint(String serverUrl) {
return UrlUtil.buildUrlFromParts(serverUrl);
}
public String getScoreResultName() {
return null != scoreResultName ? scoreResultName : DEFAULT_SCORE_RESULT_NAME;
}
public String getIdResultName() {
return null != idResultName ? idResultName : DEFAULT_ID_RESULT_NAME;
}
protected void checkResultRow(ResultRow resultRow) {
if (!resultRow.getValues().containsKey(getIdResultName())) {
dispatchInvalidResultException(getIdResultName());
}
if (!resultRow.getValues().containsKey(getScoreResultName())) {
dispatchInvalidResultException(getScoreResultName());
}
}
private void dispatchInvalidResultException(String missingKey) {
throw new RuntimeException(String.format("The cypher query result must contain the %s column name", missingKey));
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/booster/SearchResultExternalBooster.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.booster;
import com.graphaware.es.gas.cypher.CypherSettingsReader;
import com.graphaware.es.gas.domain.ExternalResult;
import com.graphaware.es.gas.domain.IndexInfo;
import com.graphaware.es.gas.util.NumberUtil;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.search.internal.InternalSearchHit;
import org.elasticsearch.search.internal.InternalSearchHits;
import java.util.*;
import static com.graphaware.es.gas.domain.ClauseConstants.*;
import static com.graphaware.es.gas.util.ParamUtil.*;
import static com.graphaware.es.gas.wrap.GraphAidedSearchActionListenerWrapper.*;
public abstract class SearchResultExternalBooster extends CypherSettingsReader implements SearchResultBooster {
protected static final String DEFAULT_SCORE_OPERATOR = MULTIPLY;
protected static final String DEFAULT_PROTOCOL = "http";
static final String DEFAULT_SCORE_RESULT_NAME = "score";
static final String DEFAULT_ID_RESULT_NAME = "id";
private int maxResultSize = -1;
private int size;
private int from;
protected String composeScoreOperator;
public SearchResultExternalBooster(Settings settings, IndexInfo indexSettings) {
super(settings, indexSettings);
}
@Override
public final void parseRequest(Map<String, Object> sourceAsMap) {
size = NumberUtil.getInt(sourceAsMap.get(SIZE), 10);
from = NumberUtil.getInt(sourceAsMap.get(FROM), 0);
Map<String, String> extParams = (Map<String, String>) sourceAsMap.get(GAS_BOOSTER_CLAUSE);
if (extParams != null) {
maxResultSize = NumberUtil.getInt(extParams.get(MAX_RESULT_SIZE), getMaxResultWindow());
composeScoreOperator = extractParameter(OPERATOR, extParams, DEFAULT_SCORE_OPERATOR);
extendedParseRequest(extParams);
validateOperator();
}
if (maxResultSize > 0) {
sourceAsMap.put(SIZE, maxResultSize);
}
sourceAsMap.put(FROM, 0);
}
@Override
public InternalSearchHits modify(final InternalSearchHits hits) {
final InternalSearchHit[] searchHits = hits.internalHits();
Map<String, InternalSearchHit> hitMap = new HashMap<>();
for (InternalSearchHit hit : searchHits) {
hitMap.put(hit.getId(), hit);
}
int totalHitsSize = hitMap.keySet().size();
Map<String, ExternalResult> remoteScore = externalDoReorder(hitMap.keySet());
final int arraySize = (size + from) < searchHits.length ? size
: (searchHits.length - from) > 0 ? (searchHits.length - from) : 0;
if (arraySize == 0) {
return new InternalSearchHits(new InternalSearchHit[0], 0, 0);
}
final int totalSize = arraySize + from;
List<InternalSearchHit> newSearchHits = new ArrayList<>(totalSize);
float maxScore = -1;
for (Map.Entry<String, InternalSearchHit> item : hitMap.entrySet()) {
ExternalResult remoteResult = remoteScore.get(item.getKey());
if (remoteResult != null) {
float newScore = composeScore(item.getValue().score(), remoteResult.getScore());
if (maxScore < newScore) {
maxScore = newScore;
}
item.getValue().score(newScore);
}
int k = 0;
while (newSearchHits.size() > 0
&& k < newSearchHits.size()
&& newSearchHits.get(k) != null
&& newSearchHits.get(k).score() > item.getValue().score()
&& k < totalSize) {
k++;
}
if (k < totalSize) {
newSearchHits.add(k, item.getValue());
}
if (newSearchHits.size() > totalSize) {
newSearchHits.remove(totalSize);
}
}
if (from > 0) {
int k = 0;
while (k < from) {
newSearchHits.remove(0);
k++;
}
}
return new InternalSearchHits(newSearchHits.toArray(new InternalSearchHit[arraySize]), totalHitsSize,
maxScore);
}
protected float composeScore(float esScore, float extScore) {
switch (getComposeScoreOperator()) {
case MULTIPLY:
return esScore * extScore;
case DIVIDE:
return esScore / extScore;
case PLUS:
return esScore + extScore;
case MINUS:
return esScore - extScore;
case REPLACE:
return extScore;
default:
return esScore;
}
}
public int getSize() {
return size;
}
public int getFrom() {
return from;
}
public int getMaxResultSize() {
return maxResultSize;
}
protected abstract Map<String, ExternalResult> externalDoReorder(Set<String> keySet);
protected void extendedParseRequest(Map<String, String> extParams) {
}
protected void validateOperator() {
Set<String> validOperators = new HashSet<>();
validOperators.add(MULTIPLY);
validOperators.add(PLUS);
validOperators.add(MINUS);
validOperators.add(DIVIDE);
validOperators.add(REPLACE);
String operator = getComposeScoreOperator();
if (!validOperators.contains(operator)) {
throw new IllegalArgumentException("Operator \"" + operator + "\" is not valid");
}
}
protected String getComposeScoreOperator() {
return composeScoreOperator != null ? composeScoreOperator : DEFAULT_SCORE_OPERATOR;
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/booster/SearchResultNeo4jBooster.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.booster;
import com.graphaware.es.gas.annotation.SearchBooster;
import com.graphaware.es.gas.domain.ExternalResult;
import com.graphaware.es.gas.domain.IndexInfo;
import com.graphaware.es.gas.util.UrlUtil;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.GenericType;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import org.codehaus.jackson.jaxrs.JacksonJsonProvider;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.sun.jersey.api.client.ClientHandlerException;
import com.sun.jersey.api.client.UniformInterfaceException;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MultivaluedMap;
import static com.graphaware.es.gas.domain.ClauseConstants.*;
@SearchBooster(name = "SearchResultNeo4jBooster")
public class SearchResultNeo4jBooster extends SearchResultExternalBooster {
private static final String DEFAULT_KEY_PROPERTY = "uuid";
private static final String DEFAULT_REST_ENDPOINT = "/graphaware/recommendation/filter";
private String boosterEndpoint = null;
private final ESLogger logger;
private String targetId;
private String keyProperty;
public SearchResultNeo4jBooster(Settings settings, IndexInfo indexSettings) {
super(settings, indexSettings);
this.logger = Loggers.getLogger(IndexInfo.INDEX_LOGGER_NAME, settings);
}
@Override
protected Map<String, ExternalResult> externalDoReorder(Set<String> keySet) {
if (logger.isDebugEnabled()) {
logger.debug("External Neo4j booster for : " + keySet);
logger.debug("Call: " + getEndpoint());
}
return getReorderedResults(getExternalResults(keySet));
}
public Map<String, ExternalResult> getReorderedResults(List<ExternalResult> externalResults) {
HashMap<String, ExternalResult> results = new HashMap<>();
for (ExternalResult item : externalResults) {
results.put(item.getObjectId(), item);
}
return results;
}
public List<ExternalResult> getExternalResults(Set<String> keySet) {
ClientConfig cfg = new DefaultClientConfig();
cfg.getClasses().add(JacksonJsonProvider.class);
WebResource resource = Client.create(cfg).resource(getEndpoint());
WebResource.Builder resBuilder = resource.accept(MediaType.APPLICATION_JSON);
setHeader(resBuilder);
ClientResponse response = null;
List<ExternalResult> externalResults = null;
try {
response = resBuilder.post(ClientResponse.class, getParameters(keySet));
GenericType<List<ExternalResult>> type = new GenericType<List<ExternalResult>>() {
};
externalResults = response.getEntity(type);
}
catch (UniformInterfaceException | ClientHandlerException ex) {
throw new RuntimeException("Error while connecting to neo4j host", ex);
}
finally {
if (response != null)
response.close();
}
if (externalResults == null) {
logger.error("Null results from neo4j endpoint");
throw new RuntimeException("Null results from neo4j endpoint. No results returned");
}
return externalResults;
}
private void setHeader(WebResource.Builder resBuilder) {
Map<String, String> headers = new HashMap<>();
if (null != getNeo4jPassword()) {
headers.put(HttpHeaders.AUTHORIZATION, UrlUtil.getAuthorizationHeaderValue(getNeo4jUsername(), getNeo4jPassword()));
}
for (String k : headers.keySet()) {
resBuilder.header(k, headers.get(k));
}
}
@Override
protected void extendedParseRequest(Map<String, String> extParams) {
targetId = extParams.get(TARGET);
keyProperty = extParams.get(KEY_PROPERTY) != null ? extParams.get(KEY_PROPERTY) : DEFAULT_KEY_PROPERTY;
boosterEndpoint = extParams.get(NEO4J_ENDPOINT);
}
public MultivaluedMap getParameters(Set<String> keySet) {
MultivaluedMap param = new MultivaluedMapImpl();
param.add("limit", String.valueOf(Integer.MAX_VALUE));
param.add("from", String.valueOf(getFrom()));
param.add("keyProperty", getKeyProperty());
param.add("ids", implodeKeySet(keySet));
return param;
}
protected String getTargetId() {
return targetId;
}
public String getKeyProperty() {
return keyProperty;
}
public String getEndpoint() {
String boosterUrl = null != boosterEndpoint ? boosterEndpoint : DEFAULT_REST_ENDPOINT;
return UrlUtil.buildUrlFromParts(getNeo4jHost(), boosterUrl, targetId);
}
public String implodeKeySet(Set<String> keySet) {
boolean isFirst = true;
String ids = "";
for (String id : keySet) {
if (!isFirst) {
ids = ids.concat(",");
}
isFirst = false;
ids = ids.concat(id);
}
return ids;
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/cypher/CypherBoltHttpEndPoint.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.cypher;
import java.util.HashMap;
import org.elasticsearch.common.settings.Settings;
import org.neo4j.driver.v1.AuthTokens;
import org.neo4j.driver.v1.Config;
import static org.neo4j.driver.v1.Config.EncryptionLevel.NONE;
import org.neo4j.driver.v1.Driver;
import org.neo4j.driver.v1.GraphDatabase;
import org.neo4j.driver.v1.Record;
import org.neo4j.driver.v1.Session;
import org.neo4j.driver.v1.StatementResult;
import org.neo4j.driver.v1.Value;
import org.neo4j.driver.v1.util.Pair;
public class CypherBoltHttpEndPoint extends CypherEndPoint {
private boolean encryption = true;
CypherBoltHttpEndPoint(Settings settings, String neo4jUrl, String neo4jUsername, String neo4jPassword, boolean encryption) {
super(settings, neo4jUrl, neo4jUsername, neo4jPassword);
this.encryption = encryption;
}
public CypherResult executeCypher(String cypherQuery) {
return executeCypher(cypherQuery, new HashMap<String, Object>());
}
@Override
public CypherResult executeCypher(String cypherQuery, HashMap<String, Object> parameters) {
try {
Driver driver;
if (encryption) {
if (getNeo4jUsername() != null) {
driver = GraphDatabase.driver(getNeo4jHost(), AuthTokens.basic(getNeo4jUsername(), getNeo4jPassword()));
} else {
driver = GraphDatabase.driver(getNeo4jHost());
}
} else {
if (getNeo4jUsername() != null) {
driver = GraphDatabase.driver(getNeo4jHost(), AuthTokens.basic(getNeo4jUsername(), getNeo4jPassword()), Config.build().withEncryptionLevel(NONE).toConfig());
} else {
driver = GraphDatabase.driver(getNeo4jHost(), Config.build().withEncryptionLevel(NONE).toConfig());
}
}
Session session = driver.session();
StatementResult response = session.run(cypherQuery, parameters);
return buildResult(response);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
private CypherResult buildResult(StatementResult response) {
CypherResult result = new CypherResult();
while (response.hasNext()) {
Record record = response.next();
ResultRow resultRow = new ResultRow();
for (Pair<String, Value> fieldInRecord : record.fields()) {
resultRow.add(fieldInRecord.key(), fieldInRecord.value());
}
result.addRow(resultRow);
}
return result;
}
@Override
public CypherResult executeCypher(HashMap<String, String> headers, String query, HashMap<String, Object> parameters) {
return executeCypher(query, parameters);
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/cypher/CypherEndPoint.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.cypher;
import com.graphaware.es.gas.domain.IndexInfo;
import java.util.HashMap;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
public abstract class CypherEndPoint {
protected final ESLogger logger;
private final String neo4jHost;
private final String neo4jPassword;
private final String neo4jUsername;
public CypherEndPoint(Settings settings, String neo4jHost) {
this(settings, neo4jHost, null, null);
}
public CypherEndPoint(Settings settings, String neo4jHost, String neo4jUsername, String neo4jPassword) {
this.neo4jHost = neo4jHost;
this.neo4jUsername = neo4jUsername;
this.neo4jPassword = neo4jPassword;
if (settings != null) {
this.logger = Loggers.getLogger(IndexInfo.INDEX_LOGGER_NAME, settings);
} else {
this.logger = Loggers.getLogger(IndexInfo.INDEX_LOGGER_NAME, Settings.EMPTY);
}
}
public String getNeo4jPassword() {
return neo4jPassword;
}
public String getNeo4jUsername() {
return neo4jUsername;
}
public String getNeo4jHost() {
return neo4jHost;
}
public abstract CypherResult executeCypher(String query, HashMap<String, Object> parameters);
public abstract CypherResult executeCypher(HashMap<String, String> headers, String query, HashMap<String, Object> parameters);
}
================================================
FILE: src/main/java/com/graphaware/es/gas/cypher/CypherEndPointBuilder.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.cypher;
import org.elasticsearch.common.settings.Settings;
public class CypherEndPointBuilder {
private Settings settings;
private String neo4jHost;
private String neo4jBoltHost;
private final CypherEndPointType protocol;
private String neo4jUsername;
private String neo4jPassword;
private boolean encryption = true;
public CypherEndPointBuilder(CypherEndPointType protocol) {
this.protocol = protocol;
}
public CypherEndPointBuilder(String protocol) {
this.protocol = CypherEndPointType.getEnum(protocol);
}
public CypherEndPointBuilder settings(Settings settings) {
this.settings = settings;
return this;
}
public CypherEndPointBuilder neo4jHostname(String neo4jHost) {
this.neo4jHost = neo4jHost;
return this;
}
public CypherEndPointBuilder neo4jBoltHostname(String neo4jBoltHost) {
this.neo4jBoltHost = neo4jBoltHost;
return this;
}
public CypherEndPointBuilder username(String neo4jUsername) {
this.neo4jUsername = neo4jUsername;
return this;
}
public CypherEndPointBuilder password(String neo4jPassword) {
this.neo4jPassword = neo4jPassword;
return this;
}
public CypherEndPointBuilder encryption(boolean encryption) {
this.encryption = encryption;
return this;
}
public CypherEndPoint build() {
checkNeo4jHost();
switch (protocol) {
case HTTP:
return new CypherHttpEndPoint(settings,
neo4jHost,
neo4jUsername,
neo4jPassword
);
case BOLT:
return new CypherBoltHttpEndPoint(settings,
neo4jBoltHost,
neo4jUsername,
neo4jPassword,
encryption);
}
throw new RuntimeException("Type " + protocol + " not supported");
}
private void checkNeo4jHost() {
if (neo4jHost == null)
throw new RuntimeException("No neo4j hosts specified for http connection in the index settings");
}
public enum CypherEndPointType {
HTTP("http"),
BOLT("bolt");
String name;
CypherEndPointType(String name) {
this.name = name;
}
public String getName() {
return name;
}
public static CypherEndPointType getEnum(String value) {
if (HTTP.getName().equalsIgnoreCase(value)) {
return HTTP;
} else if (BOLT.getName().equalsIgnoreCase(value)) {
return BOLT;
}
throw new RuntimeException("Type " + value + " not supported");
}
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/cypher/CypherHttpEndPoint.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.cypher;
import com.graphaware.es.gas.util.UrlUtil;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.GenericType;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import org.codehaus.jackson.jaxrs.JacksonJsonProvider;
import org.codehaus.jackson.map.ObjectMapper;
import org.elasticsearch.common.settings.Settings;
public class CypherHttpEndPoint extends CypherEndPoint {
private static final String CYPHER_ENDPOINT = "/db/data/transaction/commit";
private static final String CYPHER_RESPONSE_RESULTS_FIELD = "results";
private static final String CYPHER_RESPONSE_DATA_FIELD = "data";
private static final String CYPHER_RESPONSE_COLUMNS_FIELD = "columns";
private static final String CYPHER_RESPONSE_ERRORS_FIELD = "errors";
private static final String CYPHER_RESPONSE_ROW_FIELD = "row";
private final ClientConfig cfg;
private final StringBuilder stringBuilder;
private final ObjectMapper mapper;
public CypherHttpEndPoint(Settings settings, String neo4jUrl, String neo4jUsername, String neo4jPassword) {
super(settings, neo4jUrl, neo4jUsername, neo4jPassword);
cfg = new DefaultClientConfig();
cfg.getClasses().add(JacksonJsonProvider.class);
stringBuilder = new StringBuilder();
mapper = new ObjectMapper();
}
public String buildCypherQuery(String cypherQuery) {
return buildCypherQuery(cypherQuery, new HashMap<String, Object>());
}
@Override
public CypherResult executeCypher(String query, HashMap<String, Object> parameters) {
HashMap<String, String> headers = new HashMap<>();
return executeCypher(headers, query, parameters);
}
@Override
public CypherResult executeCypher(HashMap<String, String> headers, String query, HashMap<String, Object> parameters) {
String jsonBody = buildCypherQuery(query, parameters);
String cypherEndpoint = UrlUtil.buildUrlFromParts(getNeo4jHost(), CYPHER_ENDPOINT);
Map<String, Object> response = post(cypherEndpoint, headers, jsonBody);
checkErrors(response);
return buildCypherResult(response);
}
public CypherResult buildCypherResult(Map<String, Object> response) {
Map res = (Map) ((List) response.get(CYPHER_RESPONSE_RESULTS_FIELD)).get(0);
List<Map> rows = (List) res.get(CYPHER_RESPONSE_DATA_FIELD);
List<String> columns = (List) res.get(CYPHER_RESPONSE_COLUMNS_FIELD);
int k = 0;
Map<String, Integer> columnsMap = new HashMap<>();
for (String c : columns) {
columnsMap.put(c, k);
++k;
}
CypherResult result = new CypherResult();
for (Map r : rows) {
ResultRow resultRow = new ResultRow();
List row = (List) r.get(CYPHER_RESPONSE_ROW_FIELD);
for (String key : columns) {
resultRow.add(key, row.get(columnsMap.get(key)));
}
result.addRow(resultRow);
}
return result;
}
public String buildCypherQuery(String cypherQuery, Map<String, Object> parameters) {
try {
stringBuilder.append("{\"statements\" : [");
stringBuilder.append("{\"statement\" : \"").append(cypherQuery).append("\"");
if (parameters.size() > 0) {
stringBuilder.append(",").append("\"parameters\":");
stringBuilder.append(mapper.writeValueAsString(parameters));
}
stringBuilder.append("}]}");
return stringBuilder.toString();
} catch (IOException e) {
throw new RuntimeException("Unable to build the Cypher query : " + e.getMessage());
}
}
public Map<String, Object> post(String url, HashMap<String, String> headers, String json) {
if (!headers.containsKey(HttpHeaders.AUTHORIZATION) && null != getNeo4jPassword()) {
headers.put(HttpHeaders.AUTHORIZATION, UrlUtil.getAuthorizationHeaderValue(getNeo4jUsername(), getNeo4jPassword()));
}
WebResource resource = Client.create(cfg).resource(url);
WebResource.Builder builder = resource.accept(MediaType.APPLICATION_JSON)
.type(MediaType.APPLICATION_JSON)
.entity(json);
for (String k : headers.keySet()) {
builder.header(k, headers.get(k));
}
ClientResponse response = null;
Map<String, Object> results = null;
try {
response = builder.post(ClientResponse.class);
GenericType<Map<String, Object>> type = new GenericType<Map<String, Object>>() {
};
results = response.getEntity(type);
} finally {
if (response != null)
response.close();
}
if (logger.isDebugEnabled()) {
try {
ObjectMapper oWrapper = ObjectMapper.class.newInstance();
logger.debug(oWrapper.writeValueAsString(results));
} catch (InstantiationException | IllegalAccessException | IOException e) {
//
}
}
if (results == null) {
logger.error("Null results from cypher endpoint for json:\n" + json);
throw new RuntimeException("Cypher Execution Error. No results returned");
}
return results;
}
private void checkErrors(Map<String, Object> results) {
@SuppressWarnings("unchecked")
List<Map<String, Object>> errors = (List) results.get(CYPHER_RESPONSE_ERRORS_FIELD);
if (errors.size() > 0) {
throw new RuntimeException("Cypher Execution Error, message is : " + errors.get(0).toString());
}
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/cypher/CypherResult.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.cypher;
import java.util.ArrayList;
import java.util.List;
public class CypherResult {
private List<ResultRow> rows = new ArrayList<>();
public void addRow(ResultRow resultRow) {
rows.add(resultRow);
}
public List<ResultRow> getRows() {
return rows;
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/cypher/CypherSettingsReader.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.cypher;
import com.graphaware.es.gas.domain.IndexInfo;
import org.elasticsearch.common.settings.Settings;
public class CypherSettingsReader {
private final String neo4jHost;
private final String neo4jBoltHost;
private final String neo4jUsername;
private final String neo4jPassword;
private final int maxResultWindow;
private final Settings settings;
private final boolean secureBolt;
public CypherSettingsReader(Settings settings, IndexInfo indexSettings) {
this.settings = settings;
this.neo4jHost = indexSettings.getNeo4jHost();
this.neo4jBoltHost = indexSettings.getNeo4jBoltHost();
this.neo4jUsername = indexSettings.getNeo4jUsername();
this.neo4jPassword = indexSettings.getNeo4jPassword();
this.maxResultWindow = indexSettings.getMaxResultWindow();
this.secureBolt = indexSettings.isSecureBolt();
}
protected CypherEndPoint createCypherEndPoint(String protocol, Settings settings) {
return new CypherEndPointBuilder(protocol)
.settings(settings)
.neo4jHostname(getNeo4jHost())
.neo4jBoltHostname(getNeo4jBoltHost())
.username(getNeo4jUsername())
.password(getNeo4jPassword())
.encryption(isSecureBolt())
.build();
}
public String getNeo4jHost() {
return neo4jHost;
}
public String getNeo4jUsername() {
return neo4jUsername;
}
public String getNeo4jPassword() {
return neo4jPassword;
}
public int getMaxResultWindow() {
return maxResultWindow;
}
public Settings getSettings() {
return settings;
}
public boolean isSecureBolt() {
return secureBolt;
}
public String getNeo4jBoltHost() {
return neo4jBoltHost;
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/cypher/ResultRow.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.cypher;
import java.util.HashMap;
import java.util.Map;
public class ResultRow {
private Map<String, Object> items = new HashMap<>();
public void add(String columnKey, Object item) {
items.put(columnKey, item);
}
public Object get(String columnKey) {
return items.get(columnKey);
}
public Map<String, Object> getValues() {
return items;
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/domain/ClauseConstants.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.domain;
public final class ClauseConstants {
public static final String QUERY = "query";
public static final String SCORE_NAME = "scoreName";
public static final String IDENTIFIER = "identifier";
public static final String PROTOCOL = "protocol";
public static final String SIZE = "size";
public static final String FROM = "from";
public static final String MAX_RESULT_SIZE = "maxResultSize";
public static final String OPERATOR = "operator";
public static final String MULTIPLY = "*";
public static final String DIVIDE = "/";
public static final String PLUS = "+";
public static final String MINUS = "-";
public static final String REPLACE = "replace";
public static final String TARGET = "target";
public static final String KEY_PROPERTY = "keyProperty";
public static final String NEO4J_ENDPOINT = "neo4j.endpoint";
public static final String LIMIT = "limit";
public static final String IDS = "ids";
public static final String EXCLUDE = "exclude";
public static final String TRUE = "true";
public static final String QUERY_BINARY = "query_binary";
public static final String NAME = "name";
private ClauseConstants() {
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/domain/ExternalResult.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.domain;
public class ExternalResult {
private long nodeId;
private String objectId;
//private String item;
private float score;
public ExternalResult() {
}
public ExternalResult(String objectId, float score) {
this.objectId = objectId;
this.score = score;
}
public long getNodeId() {
return nodeId;
}
public void setNodeId(long nodeId) {
this.nodeId = nodeId;
}
public String getObjectId() {
return objectId;
}
public void setObjectId(String uuid) {
this.objectId = uuid;
}
// public String getItem() {
// return item;
// }
//
// public void setItem(String item) {
// this.item = item;
// }
public float getScore() {
return score;
}
public void setScore(float score) {
this.score = score;
}
///todo this is not used anywhere:
// class Neo4JResultComparator implements Comparator<ExternalResult> {
//
// @Override
// public int compare(ExternalResult o1, ExternalResult o2) {
// if (o1.score < o2.score) {
// return -1;
// }
// if (o1.score > o2.score) {
// return 1;
// }
// return 0;
// }
//
// }
}
================================================
FILE: src/main/java/com/graphaware/es/gas/domain/IndexInfo.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.domain;
public class IndexInfo {
public static final String INDEX_LOGGER_NAME = "index.graph-aided-search";
public final static IndexInfo NO_SCRIPT_INFO = new IndexInfo();
private final String neo4jHost;
private final String neo4jBoltHost;
private String neo4jUsername;
private String neo4jPwd;
private final boolean enabled;
private final int maxResultWindow;
private boolean secureBolt = true;
IndexInfo() {
this.neo4jHost = "http://localhost:7474";
this.neo4jBoltHost = null;
this.enabled = false;
this.maxResultWindow = 0;
}
public IndexInfo(final String hostname, final String username, final String password, boolean enabled, int maxResultWindow) {
this(hostname, null, username, password, enabled, maxResultWindow);
}
public IndexInfo(final String hostname, final String boltHostname, final String username, final String password, boolean enabled, int maxResultWindow, boolean secureBolt) {
this(hostname, boltHostname, username, password, enabled, maxResultWindow);
this.secureBolt = secureBolt;
}
public IndexInfo(final String hostname, final String boltHostname, final String username, final String password, boolean enabled, int maxResultWindow) {
this(hostname, boltHostname, enabled, maxResultWindow);
this.neo4jUsername = username;
this.neo4jPwd = password;
}
public IndexInfo(final String hostname, boolean enabled, int maxResultWindow) {
this(hostname, null, enabled, maxResultWindow);
}
public IndexInfo(final String hostname, final String boltHostname, boolean enabled, int maxResultWindow) {
this.neo4jHost = hostname;
this.neo4jBoltHost = boltHostname;
this.enabled = enabled;
this.maxResultWindow = maxResultWindow;
}
public String getNeo4jHost() {
return neo4jHost;
}
public boolean isEnabled() {
return enabled;
}
public int getMaxResultWindow() {
return maxResultWindow;
}
@Override
public String toString() {
return "ScriptInfo [neo4jHost=" + neo4jHost
+ ", enabled=" + enabled
+ ", maxResultWindow=" + maxResultWindow
+ ", neo4jUsername=" + neo4jUsername
+ ", neo4jPwd=" + neo4jPwd
+ "]";
}
public String getNeo4jUsername() {
return neo4jUsername;
}
public String getNeo4jPassword() {
return neo4jPwd;
}
public String getNeo4jBoltHost() {
return neo4jBoltHost;
}
public boolean isSecureBolt() {
return secureBolt;
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/filter/SearchResultCypherFilter.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.filter;
import com.graphaware.es.gas.annotation.SearchFilter;
import com.graphaware.es.gas.cypher.CypherEndPoint;
import com.graphaware.es.gas.cypher.CypherResult;
import com.graphaware.es.gas.cypher.CypherSettingsReader;
import com.graphaware.es.gas.cypher.ResultRow;
import com.graphaware.es.gas.domain.IndexInfo;
import com.graphaware.es.gas.util.NumberUtil;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.search.internal.InternalSearchHit;
import org.elasticsearch.search.internal.InternalSearchHits;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import static com.graphaware.es.gas.domain.ClauseConstants.*;
import static com.graphaware.es.gas.wrap.GraphAidedSearchActionListenerWrapper.GAS_FILTER_CLAUSE;
@SearchFilter(name = "SearchResultCypherFilter")
public class SearchResultCypherFilter extends CypherSettingsReader implements SearchResultFilter {
private static final Logger logger = Logger.getLogger(SearchResultCypherFilter.class.getName());
private static final String DEFAULT_ID_RESULT_NAME = "id";
private static final String ID_RESULT_NAME_KEY = "identifier";
private static final int DEFAULT_RESULT_SIZE = 10;
private static final int DEFAULT_FROM_VALUE = 0;
protected static final String DEFAULT_PROTOCOL = "http";
private int maxResultSize = -1;
private CypherEndPoint cypherEndPoint;
private int size;
private int from;
private String cypherQuery;
private boolean shouldExclude = true;
private String idResultName;
public SearchResultCypherFilter(Settings settings, IndexInfo indexSettings) {
super(settings, indexSettings);
}
@Override
public void parseRequest(Map<String, Object> sourceAsMap) {
size = NumberUtil.getInt(sourceAsMap.get(SIZE), DEFAULT_RESULT_SIZE);
from = NumberUtil.getInt(sourceAsMap.get(FROM), DEFAULT_FROM_VALUE);
HashMap extParams = (HashMap) sourceAsMap.get(GAS_FILTER_CLAUSE);
if (extParams != null) {
cypherQuery = (String) extParams.get(QUERY);
maxResultSize = NumberUtil.getInt(extParams.get(MAX_RESULT_SIZE), getMaxResultWindow());
shouldExclude = extParams.containsKey(EXCLUDE) && String.valueOf(extParams.get(EXCLUDE)).equalsIgnoreCase(TRUE);
idResultName = extParams.containsKey(ID_RESULT_NAME_KEY) ? String.valueOf(extParams.get(ID_RESULT_NAME_KEY)) : null;
String protocol = extParams.containsKey(PROTOCOL) ? String.valueOf(extParams.get(PROTOCOL)) : DEFAULT_PROTOCOL;
cypherEndPoint = createCypherEndPoint(protocol, getSettings());
}
if (maxResultSize > 0) {
sourceAsMap.put(SIZE, maxResultSize);
}
if (null == cypherQuery) {
throw new RuntimeException("The Query Parameter is required in gas-filter");
}
}
@Override
public InternalSearchHits modify(final InternalSearchHits hits) {
Set<String> remoteFilter = getFilteredItems();
final InternalSearchHit[] searchHits = hits.internalHits();
Map<String, InternalSearchHit> hitMap = new HashMap<>();
for (InternalSearchHit hit : searchHits) {
hitMap.put(hit.getId(), hit);
}
InternalSearchHit[] tmpSearchHits = new InternalSearchHit[hitMap.size()];
int k = 0;
float maxScore = -1;
for (Map.Entry<String, InternalSearchHit> item : hitMap.entrySet()) {
if ((shouldExclude && !remoteFilter.contains(item.getKey()))
|| (!shouldExclude && remoteFilter.contains(item.getKey()))) {
tmpSearchHits[k] = item.getValue();
k++;
float score = item.getValue().getScore();
if (maxScore < score) {
maxScore = score;
}
}
}
int totalSize = k;
logger.log(Level.FINE, "k <= reorderSize: {0}", (k <= size));
final int arraySize = (size + from) < k ? size
: (k - from) > 0 ? (k - from) : 0;
if (arraySize == 0) {
return new InternalSearchHits(new InternalSearchHit[0], 0, 0);
}
InternalSearchHit[] newSearchHits = new InternalSearchHit[arraySize];
k = 0;
for (int i = from; i < arraySize + from; i++) {
InternalSearchHit newId = tmpSearchHits[i];
if (newId == null) {
break;
}
newSearchHits[k++] = newId;
}
return new InternalSearchHits(newSearchHits, totalSize,
hits.maxScore());
}
protected Set<String> getFilteredItems() {
CypherResult result = getCypherResult();
Set<String> filteredItems = new HashSet<>();
for (ResultRow resultRow : result.getRows()) {
filteredItems.add(getFilteredItem(resultRow));
}
return filteredItems;
}
protected CypherResult getCypherResult() {
return cypherEndPoint.executeCypher(cypherQuery, new HashMap<String, Object>());
}
protected String getFilteredItem(ResultRow resultRow) {
if (!resultRow.getValues().containsKey(getIdResultName())) {
throw new RuntimeException("The cypher query result must contain the " + getIdResultName() + " column name");
}
return getIdentifier(resultRow.get(getIdResultName()));
}
public int getSize() {
return size;
}
public int getFrom() {
return from;
}
public String getIdResultName() {
return null != idResultName ? idResultName : DEFAULT_ID_RESULT_NAME;
}
private static String getIdentifier(Object objectId) {
if (objectId instanceof String) {
return (String) objectId;
}
return String.valueOf(objectId);
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/filter/SearchResultFilter.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.filter;
import com.graphaware.es.gas.modifier.SearchResultModifier;
public interface SearchResultFilter extends SearchResultModifier {
}
================================================
FILE: src/main/java/com/graphaware/es/gas/modifier/PrivilegedSearchResultModifier.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.modifier;
import org.elasticsearch.search.internal.InternalSearchHits;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Map;
public class PrivilegedSearchResultModifier implements SearchResultModifier {
private final SearchResultModifier delegate;
public PrivilegedSearchResultModifier(SearchResultModifier delegate) {
this.delegate = delegate;
}
@Override
public InternalSearchHits modify(final InternalSearchHits hits) {
return AccessController.doPrivileged(new PrivilegedAction<InternalSearchHits>() {
@Override
public InternalSearchHits run() {
return delegate.modify(hits);
}
});
}
@Override
public void parseRequest(Map<String, Object> sourceAsMap) {
delegate.parseRequest(sourceAsMap);
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/modifier/SearchResultModifier.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.modifier;
import org.elasticsearch.search.internal.InternalSearchHits;
import java.util.Map;
public interface SearchResultModifier {
InternalSearchHits modify(final InternalSearchHits hits);
void parseRequest(Map<String, Object> sourceAsMap);
}
================================================
FILE: src/main/java/com/graphaware/es/gas/util/Instantiator.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.util;
import com.graphaware.es.gas.domain.IndexInfo;
import com.graphaware.es.gas.modifier.SearchResultModifier;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import static com.graphaware.es.gas.domain.ClauseConstants.NAME;
public class Instantiator {
private final ESLogger logger;
private final Settings settings;
private final Map<Class<? extends SearchResultModifier>, Map<String, ?>> classCache = new ConcurrentHashMap<>();
public Instantiator(Settings settings) {
this.logger = Loggers.getLogger(getClass(), settings);
this.settings = settings;
}
@SuppressWarnings("unchecked")
public <T extends SearchResultModifier> T instantiate(String clause, Map<String, Object> source, IndexInfo indexInfo, final Class<T> clazz, final Class<? extends Annotation> annotationClass) {
Map<String, String> params = (Map<String, String>) source.get(clause);
if (params == null) {
return null;
}
String name = params.get(NAME);
if (name == null || name.length() < 1) {
return null;
}
T result = instantiatePrivileged(name, indexInfo, clazz, annotationClass);
if (result != null) {
result.parseRequest(source);
} else {
logger.warn("No {} found with name {}", clazz.getName(), name);
}
source.remove(clause);
return result;
}
private <T extends SearchResultModifier> T instantiatePrivileged(final String name, final IndexInfo indexSettings, final Class<T> clazz, final Class<? extends Annotation> annotationClass) {
return AccessController.doPrivileged(new PrivilegedAction<T>() {
public T run() {
return instantiate(name, indexSettings, clazz, annotationClass);
}
});
}
private <T extends SearchResultModifier> T instantiate(String name, IndexInfo indexSettings, Class<T> clazz, Class<? extends Annotation> annotationClass) {
Class<T> cls = loadCachedClasses(clazz, annotationClass).get(name.toLowerCase());
if (cls == null) {
return null;
}
try {
try {
Constructor<T> constructor = cls.getConstructor(Settings.class, IndexInfo.class);
return constructor.newInstance(settings, indexSettings);
} catch (NoSuchMethodException ex) {
logger.warn("No constructor with settings for class {}. Using default", cls.getName());
return cls.newInstance();
}
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | SecurityException ex) {
logger.error("Error while initializing new {}", cls.getName(), ex);
}
return null;
}
private <T extends SearchResultModifier> Map<String, Class<T>> loadCachedClasses(Class<T> clazz, Class<? extends Annotation> annotationClass) {
@SuppressWarnings("unchecked")
Map<String, Class<T>> cachedMap = (Map<String, Class<T>>) classCache.get(clazz);
if (cachedMap == null) {
cachedMap = loadClasses(clazz, annotationClass);
classCache.put(clazz, cachedMap);
}
return cachedMap;
}
private <T> Map<String, Class<T>> loadClasses(Class<T> clazz, Class<? extends Annotation> annotationClass) {
Collection<Class<T>> classes = PluginClassLoader.loadClass(clazz, annotationClass).values();
Map<String, Class<T>> result = new HashMap<>();
for (Class<T> cls : classes) {
Annotation annotation = cls.getAnnotation(annotationClass);
try {
Method nameMethod = annotationClass.getDeclaredMethod("name");
result.put(((String) nameMethod.invoke(annotation)).toLowerCase(), cls);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
return result;
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/util/NumberUtil.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.util;
public final class NumberUtil {
public static int getInt(final Object value, final int defaultValue) {
if (value instanceof Number) {
return ((Number) value).intValue();
} else if (value instanceof String) {
return Integer.parseInt(value.toString());
}
return defaultValue;
}
public static float getFloat(final Object value) {
if (value instanceof Number) {
return ((Number) value).floatValue();
} else if (value instanceof String) {
return Float.parseFloat(value.toString());
}
throw new RuntimeException("Unable to parse float from value");
}
private NumberUtil() {
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/util/ParamUtil.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.util;
import java.util.Map;
public final class ParamUtil {
public static <T> T extractParameter(String name, Map<String, T> params) {
T value = params.get(name);
if (value == null) {
throw new IllegalStateException("The " + name + " parameter must not be null");
}
return value;
}
public static <T> T extractParameter(String name, Map<String, T> params, T defaultValue) {
T value = params.get(name);
return value != null ? value : defaultValue;
}
private ParamUtil() {
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/util/PluginClassLoader.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.util;
import java.lang.annotation.Annotation;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.reflections.Reflections;
public final class PluginClassLoader {
private static Reflections reflections;
public static <T, A extends Annotation> Map<String, Class<T>> loadClass(Class<T> type, Class<A> annotation) {
return loadClassByAnnotation(type, annotation);
}
private static <T, A extends Annotation> Map<String, Class<T>> loadClassByAnnotation(Class<T> type, Class<A> annotation) {
if (reflections == null) {
loadReflections("com.graphaware.es.gas");
}
Map<String, Class<T>> loader = new HashMap<>();
Set<Class<?>> providers = reflections.getTypesAnnotatedWith(annotation);
for (Class<?> item : providers) {
loader.put(item.getName(), (Class<T>) item);
}
return loader;
}
private static void loadReflections(final String packagePath) {
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
reflections = new Reflections(packagePath);
return null; // nothing to return
}
});
}
private PluginClassLoader() {
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/util/UrlUtil.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.util;
import com.google.common.io.BaseEncoding;
public class UrlUtil {
public static String buildUrlFromParts(String... parts) {
boolean isFirst = true;
String url = "";
for (String part : parts) {
while (part.endsWith("/")) {
part = part.substring(0, part.length()-1);
}
while (part.startsWith("/")) {
part = part.substring(1, part.length());
}
if (!isFirst) {
url += "/";
}
url += part;
isFirst = false;
}
return url;
}
private UrlUtil() {
}
public static String getAuthorizationHeaderValue(String username, String password) {
String value = username + ":" + password;
return "Basic " + BaseEncoding.base64().encode(value.getBytes());
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/wrap/ActionListenerWrapper.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.wrap;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.common.xcontent.StatusToXContent;
public interface ActionListenerWrapper<T extends StatusToXContent> {
ActionListener<T> wrap(final SearchRequest request, final ActionListener<T> listener) throws CannotWrapException;
}
================================================
FILE: src/main/java/com/graphaware/es/gas/wrap/CannotWrapException.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.wrap;
public class CannotWrapException extends Exception {
public CannotWrapException(String message) {
super(message);
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/wrap/GraphAidedSearchActionListenerWrapper.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.wrap;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.graphaware.es.gas.annotation.SearchBooster;
import com.graphaware.es.gas.annotation.SearchFilter;
import com.graphaware.es.gas.booster.SearchResultBooster;
import com.graphaware.es.gas.domain.IndexInfo;
import com.graphaware.es.gas.filter.SearchResultFilter;
import com.graphaware.es.gas.modifier.PrivilegedSearchResultModifier;
import com.graphaware.es.gas.modifier.SearchResultModifier;
import com.graphaware.es.gas.util.Instantiator;
import com.graphaware.es.gas.util.NumberUtil;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.Requests;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.metadata.AliasOrIndex;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.search.lookup.SourceLookup;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import static com.graphaware.es.gas.domain.ClauseConstants.*;
public class GraphAidedSearchActionListenerWrapper implements ActionListenerWrapper<SearchResponse> {
public static final String INDEX_GA_ES_NEO4J_ENABLED = "index.gas.enable";
public static final String INDEX_MAX_RESULT_WINDOW = "max_result_window";
public static final String INDEX_GA_ES_NEO4J_HOST = "index.gas.neo4j.hostname";
public static final String INDEX_GA_ES_NEO4J_USER = "index.gas.neo4j.user";
public static final String INDEX_GA_ES_NEO4J_PWD = "index.gas.neo4j.password";
public static final String INDEX_GA_ES_NEO4J_BOLT_HOST = "index.gas.neo4j.boltHostname";
public static final String INDEX_GA_ES_NEO4J_BOLT_SECURE = "index.gas.neo4j.bolt.secure";
//
public static final String GAS_REQUEST = "_gas";
public static final String GAS_BOOSTER_CLAUSE = "gas-booster";
public static final String GAS_FILTER_CLAUSE = "gas-filter";
//
public static final int DEFAULT_MAX_RESULT_WINDOW = 10000;
private final ESLogger logger;
private final Settings settings;
private final Instantiator instantiator;
private final ClusterService clusterService;
private final Cache<String, IndexInfo> scriptInfoCache;
//private final Client client;
public GraphAidedSearchActionListenerWrapper(Settings settings, ClusterService clusterService, Client client) {
this.logger = Loggers.getLogger(getClass(), settings);
this.settings = settings;
this.instantiator = new Instantiator(settings);
this.clusterService = clusterService;
//this.client = client;
this.scriptInfoCache = CacheBuilder.newBuilder().concurrencyLevel(16).expireAfterAccess(120, TimeUnit.SECONDS).build();
}
@Override
public ActionListener<SearchResponse> wrap(SearchRequest request, ActionListener<SearchResponse> listener) throws CannotWrapException {
checkCorrectType(request);
checkScroll(request);
checkNotAlreadyWrapped(request);
checkSource(request);
checkIndex(request);
final long startTime = System.nanoTime();
final Map<String, Object> source = SourceLookup.sourceAsMap(request.source());
warnIfQueryBinary(source);
final int size = NumberUtil.getInt(source.get(SIZE), 10);
final int from = NumberUtil.getInt(source.get(FROM), 0);
checkSizeAndFrom(size, from);
final IndexInfo scriptInfo = getScriptInfo(request.indices()[0]);
List<SearchResultModifier> modifiers = produceModifiers(scriptInfo, source);
request.source(buildBytes(source));
return createActionListener(request, listener, source, size, from, new WrappingActionListener(listener, startTime, modifiers, scriptInfo, settings));
}
private void checkCorrectType(SearchRequest request) throws CannotWrapException {
switch (request.searchType()) {
case DFS_QUERY_AND_FETCH:
case QUERY_AND_FETCH:
case QUERY_THEN_FETCH:
return;
default:
throw new CannotWrapException("Incorrect type: " + request.searchType());
}
}
private void checkScroll(SearchRequest request) throws CannotWrapException {
if (request.scroll() != null) {
throw new CannotWrapException("Has scroll");
}
}
private void checkNotAlreadyWrapped(SearchRequest request) throws CannotWrapException {
//Necessary to avoid infinite loop
if (Boolean.FALSE.equals(request.getHeader(GAS_REQUEST))) {
throw new CannotWrapException("Already wrapped");
}
}
private void checkSource(SearchRequest request) throws CannotWrapException {
BytesReference source = request.source();
if (source == null) {
source = request.extraSource();
if (source == null) {
throw new CannotWrapException("No source");
}
}
}
private void checkIndex(SearchRequest request) throws CannotWrapException {
final String[] indices = request.indices();
if (indices == null || indices.length != 1) {
throw new CannotWrapException("Does not have a single index");
}
}
private void warnIfQueryBinary(Map<String, Object> sourceAsMap) {
if (sourceAsMap.get(QUERY_BINARY) != null) {
String query = new String((byte[]) sourceAsMap.get(QUERY_BINARY));
logger.warn("Binary query not supported: \n" + query);
}
}
private void checkSizeAndFrom(int size, int from) throws CannotWrapException {
if (size < 0 || from < 0) {
throw new CannotWrapException("Negative size or from");
}
}
private List<SearchResultModifier> produceModifiers(IndexInfo scriptInfo, Map<String, Object> source) throws CannotWrapException {
List<SearchResultModifier> modifiers = new LinkedList<>();
SearchResultBooster booster = instantiator.instantiate(GAS_BOOSTER_CLAUSE, source, scriptInfo, SearchResultBooster.class, SearchBooster.class);
if (booster != null) {
modifiers.add(new PrivilegedSearchResultModifier(booster));
}
SearchResultFilter filter = instantiator.instantiate(GAS_FILTER_CLAUSE, source, scriptInfo, SearchResultFilter.class, SearchFilter.class);
if (filter != null) {
modifiers.add(new PrivilegedSearchResultModifier(filter));
}
if (modifiers.isEmpty()) {
throw new CannotWrapException("No modifiers");
}
return modifiers;
}
private BytesReference buildBytes(Map<String, Object> source) {
final XContentBuilder builder;
try {
builder = XContentFactory.contentBuilder(Requests.CONTENT_TYPE);
builder.map(source);
} catch (IOException e) {
throw new RuntimeException(e);
}
return builder.bytes();
}
private ActionListener<SearchResponse> createActionListener(final SearchRequest request, final ActionListener<SearchResponse> listener, final Map<String, Object> source, final int size, final int from, final ActionListener<SearchResponse> searchResponseListener) {
return new ActionListener<SearchResponse>() {
@Override
public void onResponse(SearchResponse response) {
searchResponseListener.onResponse(response);
}
@Override
public void onFailure(Throwable t) {
searchResponseListener.onFailure(t);
}
};
}
private IndexInfo getScriptInfo(final String index) {
try {
return scriptInfoCache.get(index, new Callable<IndexInfo>() {
@Override
public IndexInfo call() throws Exception {
final MetaData metaData = clusterService.state().getMetaData();
AliasOrIndex aliasOrIndex = metaData.getAliasAndIndexLookup().get(index);
if (aliasOrIndex == null) {
return IndexInfo.NO_SCRIPT_INFO;
}
Settings indexSettings = null;
for (IndexMetaData indexMD : aliasOrIndex.getIndices()) {
final Settings scriptSettings = indexMD.getSettings();
final String script = scriptSettings.get(INDEX_GA_ES_NEO4J_HOST);
if (script != null && script.length() > 0) {
indexSettings = scriptSettings;
}
}
if (indexSettings == null) {
return IndexInfo.NO_SCRIPT_INFO;
}
return new IndexInfo(indexSettings.get(INDEX_GA_ES_NEO4J_HOST),
indexSettings.get(INDEX_GA_ES_NEO4J_BOLT_HOST),
indexSettings.get(INDEX_GA_ES_NEO4J_USER),
indexSettings.get(INDEX_GA_ES_NEO4J_PWD),
indexSettings.getAsBoolean(INDEX_GA_ES_NEO4J_ENABLED, false),
indexSettings.getAsInt(INDEX_MAX_RESULT_WINDOW,
DEFAULT_MAX_RESULT_WINDOW),
indexSettings.getAsBoolean(INDEX_GA_ES_NEO4J_BOLT_SECURE, true));
}
});
} catch (final Exception e) {
logger.warn("Failed to load ScriptInfo for {}.", e, index);
return null;
}
}
}
================================================
FILE: src/main/java/com/graphaware/es/gas/wrap/WrappingActionListener.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas.wrap;
import com.graphaware.es.gas.domain.IndexInfo;
import com.graphaware.es.gas.modifier.SearchResultModifier;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.ShardSearchFailure;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.search.aggregations.InternalAggregations;
import org.elasticsearch.search.internal.InternalSearchHits;
import org.elasticsearch.search.internal.InternalSearchResponse;
import org.elasticsearch.search.profile.InternalProfileShardResults;
import org.elasticsearch.search.suggest.Suggest;
import org.elasticsearch.transport.netty.ChannelBufferStreamInput;
import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import static org.elasticsearch.action.search.ShardSearchFailure.readShardSearchFailure;
import org.elasticsearch.search.internal.InternalSearchHit;
import static org.elasticsearch.search.internal.InternalSearchHits.readSearchHits;
import static org.elasticsearch.search.internal.InternalSearchHits.readSearchHits;
public class WrappingActionListener implements ActionListener<SearchResponse> {
private final ESLogger logger;
private final ActionListener<SearchResponse> wrapped;
private final long startTime;
private final List<SearchResultModifier> modifiers;
private final IndexInfo indexInfo;
public WrappingActionListener(ActionListener<SearchResponse> wrapped, long startTime, List<SearchResultModifier> modifiers, IndexInfo indexInfo, Settings settings) {
this.logger = Loggers.getLogger(getClass(), settings);
this.wrapped = wrapped;
this.startTime = startTime;
this.modifiers = modifiers;
this.indexInfo = indexInfo;
}
@Override
public void onResponse(final SearchResponse response) {
if (response.getHits().getTotalHits() == 0 || !indexInfo.isEnabled()) {
wrapped.onResponse(response);
return;
}
if (logger.isDebugEnabled()) {
logger.debug("Boosting results: {}", response);
}
try {
wrapped.onResponse(handleResponse(response, startTime, modifiers));
} catch (final Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("Failed to parse a search response.", e);
}
throw new RuntimeException("Failed to parse a search response.", e);
}
}
@Override
public void onFailure(final Throwable e) {
wrapped.onFailure(e);
}
private SearchResponse handleResponse(final SearchResponse response, final long startTime, final List<SearchResultModifier> modifiers) throws IOException {
BytesStreamOutput out = new BytesStreamOutput();
response.writeTo(out);
ChannelBufferStreamInput in = new ChannelBufferStreamInput(out.bytes().toChannelBuffer());
Map<String, Object> headers = readHeaders(in);
InternalSearchHits hits = modifyHits(modifiers, readHits(in));
InternalAggregations aggregations = readAggregations(in);
Suggest suggest = readSuggestions(in);
Boolean timedOut = in.readBoolean();
Boolean terminatedEarly = in.readOptionalBoolean();
InternalProfileShardResults profileResults = readInternalProfileShardResults(in);
InternalSearchResponse internalResponse = new InternalSearchResponse(hits, aggregations, suggest, profileResults, timedOut, terminatedEarly);
SearchResponse newResponse = createNewResponse(startTime, in, internalResponse);
copyHeaders(headers, newResponse);
logTime(response, startTime);
return newResponse;
}
private Map<String, Object> readHeaders(ChannelBufferStreamInput in) throws IOException {
if (logger.isDebugEnabled()) {
logger.debug("Reading headers...");
}
Map<String, Object> headers = null;
if (in.readBoolean()) {
headers = in.readMap();
}
return headers;
}
private InternalSearchHits readHits(ChannelBufferStreamInput in) throws IOException {
if (logger.isDebugEnabled()) {
logger.debug("Reading hits...");
}
return readSearchHits(in);
}
private InternalSearchHits modifyHits(List<SearchResultModifier> modifiers, InternalSearchHits hits) {
for (final SearchResultModifier modifier : modifiers) {
hits = modifier.modify(hits);
}
InternalSearchHit[] searchHits = sortResults(hits);
return new InternalSearchHits(searchHits, hits.getTotalHits(),
hits.maxScore());
}
private InternalSearchHit[] sortResults(InternalSearchHits hits) {
final InternalSearchHit[] searchHits = hits.internalHits();
Arrays.sort(searchHits, new Comparator<InternalSearchHit>() {
@Override
public int compare(InternalSearchHit o1, InternalSearchHit o2) {
if (o1 == null && o2 != null)
return -1;
else if (o1 != null && o2 == null)
return 1;
else if (o1 == null && o2 == null)
return 0;
else if (o1.getScore() > o2.getScore())
return -1;
else if (o1.getScore() < o2.getScore())
return 1;
else
return 0;
}
});
return searchHits;
}
private InternalAggregations readAggregations(ChannelBufferStreamInput in) throws IOException {
if (logger.isDebugEnabled()) {
logger.debug("Reading aggregations...");
}
InternalAggregations aggregations = null;
if (in.readBoolean()) {
aggregations = InternalAggregations.readAggregations(in);
}
return aggregations;
}
private Suggest readSuggestions(ChannelBufferStreamInput in) throws IOException {
if (logger.isDebugEnabled()) {
logger.debug("Reading suggest...");
}
Suggest suggest = null;
if (in.readBoolean()) {
suggest = Suggest.readSuggest(Suggest.Fields.SUGGEST, in);
}
return suggest;
}
private InternalProfileShardResults readInternalProfileShardResults(ChannelBufferStreamInput in) throws IOException {
InternalProfileShardResults profileResults;
if (in.getVersion().onOrAfter(Version.V_2_2_0) && in.readBoolean()) {
profileResults = new InternalProfileShardResults(in);
} else {
profileResults = null;
}
return profileResults;
//return new InternalSearchResponse(hits, aggregations, suggest, profileResults, timedOut, terminatedEarly);
}
private SearchResponse createNewResponse(long startTime, ChannelBufferStreamInput in, InternalSearchResponse internalResponse) throws IOException {
int totalShards = in.readVInt();
int successfulShards = in.readVInt();
int size = in.readVInt();
ShardSearchFailure[] shardFailures;
if (size == 0) {
shardFailures = ShardSearchFailure.EMPTY_ARRAY;
} else {
shardFailures = new ShardSearchFailure[size];
for (int i = 0; i < shardFailures.length; i++) {
shardFailures[i] = readShardSearchFailure(in);
}
}
final String scrollId = in.readOptionalString();
if (logger.isDebugEnabled()) {
logger.debug("Creating new SearchResponse...");
}
return new SearchResponse(internalResponse, scrollId, totalShards, successfulShards, (System.nanoTime() - startTime) / 1000000, shardFailures);
}
private void copyHeaders(Map<String, Object> headers, SearchResponse newResponse) {
if (headers != null) {
for (Map.Entry<String, Object> entry : headers.entrySet()) {
newResponse.putHeader(entry.getKey(), entry.getValue());
}
}
}
private void logTime(SearchResponse response, long startTime) {
if (logger.isDebugEnabled()) {
long tookInMillis = (System.nanoTime() - startTime) / 1000000;
logger.debug("Rewriting overhead time: {} - {} = {}ms", tookInMillis, response.getTookInMillis(), tookInMillis - response.getTookInMillis());
}
}
}
================================================
FILE: src/main/plugin-metadata/plugin-descriptor.properties
================================================
#
# Copyright (c) 2013-2016 GraphAware
#
# This file is part of the GraphAware Framework.
#
# GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation, either
# version 3 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details. You should have received a copy of
# the GNU General Public License along with this program. If not, see
# <http://www.gnu.org/licenses/>.
#
description=This plugin allow to boosting and filtering results based on neo4j graph databases
version=${project.version}
name=graph-aided-search
jvm=true
classname=${elasticsearch.plugin.classname}
elasticsearch.version=${elasticsearch.version}
java.version=${maven.compiler.target}
isolated=true
================================================
FILE: src/main/plugin-metadata/plugin-security.policy
================================================
grant {
//permission org.elasticsearch.script.ClassPermission "java.lang.*"; // allow class`
//permission java.lang.RuntimePermission "createClassLoader";
permission java.lang.RuntimePermission "getClassLoader";
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
//permission java.lang.RuntimePermission "accessDeclaredMembers";
//permission java.lang.RuntimePermission "accessClassInPackage.sun.reflect";
//permission java.lang.RuntimePermission "closeClassLoader";
//permission org.elasticsearch.script.ClassPermission "<<STANDARD>>";
};
================================================
FILE: src/test/java/com/graphaware/es/gas/EmbeddedGraphDatabaseServerTest.java
================================================
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.graphaware.es.gas;
import com.graphaware.integration.neo4j.test.EmbeddedGraphDatabaseServer;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
/**
*
* @author ale
*/
public class EmbeddedGraphDatabaseServerTest {
private EmbeddedGraphDatabaseServer server;
public EmbeddedGraphDatabaseServerTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
server = new EmbeddedGraphDatabaseServer();
server.start();
}
@After
public void tearDown() {
server.stop();
}
@Test
public void someTest() {
System.out.print("But a bp here");
}
}
================================================
FILE: src/test/java/com/graphaware/es/gas/GraphAidedSearchFilterTest.java
================================================
package com.graphaware.es.gas;
import org.elasticsearch.common.settings.Settings;
import org.junit.Test;
import static org.junit.Assert.*;
public class GraphAidedSearchFilterTest {
@Test
public void testDefaultFilterOrder() {
Settings settings = Settings.EMPTY;
GraphAidedSearchFilter filter = new GraphAidedSearchFilter(settings);
assertEquals(10, filter.order());
}
@Test
public void testCustomFilterOrder() {
Settings settings = Settings.builder()
.put("indices.graphaware.filter.order", 25)
.build();
GraphAidedSearchFilter filter = new GraphAidedSearchFilter(settings);
assertEquals(25, filter.order());
}
}
================================================
FILE: src/test/java/com/graphaware/es/gas/GraphAidedSearchIntegrationBoltTest.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas;
import com.graphaware.es.gas.cypher.CypherEndPoint;
import com.graphaware.es.gas.cypher.CypherEndPointBuilder;
import io.searchbox.core.Search;
import io.searchbox.core.SearchResult;
import org.junit.Test;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static com.graphaware.es.gas.wrap.GraphAidedSearchActionListenerWrapper.*;
import com.graphaware.integration.neo4j.test.EmbeddedGraphDatabaseServer;
import org.elasticsearch.common.settings.Settings;
import static org.junit.Assert.assertEquals;
public class GraphAidedSearchIntegrationBoltTest extends GraphAidedSearchTest {
private static final String INDEX_NAME = "test-index";
private static final String DISABLED_INDEX_NAME = "disabled-test-index";
private static final String TYPE_NAME = "test_data";
protected static final String BOLT_URL = "bolt://localhost:7687";
protected static final String HTTP_URL = "http://localhost:7474";
private CypherEndPoint cypherEndPoint;
@Override
public void setUp() throws Exception {
super.setUp();
createIndices();
createData();
}
protected void createNeo4jServer() throws IOException {
neo4jServer = new EmbeddedGraphDatabaseServer();
Map<String, Object> serverParams = new HashMap<>();
serverParams.put("dbms.connector.0.enabled", true);
neo4jServer.start(serverParams);
cypherEndPoint = new CypherEndPointBuilder(CypherEndPointBuilder.CypherEndPointType.BOLT)
.neo4jHostname(HTTP_URL)
.neo4jBoltHostname(BOLT_URL)
.settings(Settings.EMPTY)
.encryption(false)
.build();
}
@Override
protected HashMap<String, Object> clusterSettings() {
HashMap<String, Object> settings = new HashMap<>();
settings.put("script.search", "on");
settings.put("http.cors.enabled", true);
settings.put("http.cors.allow-origin", "*");
settings.put("index.number_of_shards", 3);
settings.put("index.number_of_replicas", 0);
settings.put("discovery.zen.ping.unicast.hosts", "localhost:9301-9310");
settings.put("plugin.types", "com.graphaware.es.gas.GraphAidedSearchPlugin");
settings.put("index.unassigned.node_left.delayed_timeout", "0");
return settings;
}
@Test
public void testCypherFilterWithGraphAndBolt() throws IOException {
executeCypher("UNWIND range(0, 100) as x CREATE (n) SET n.id = x");
String query = "{"
+ " \"query\": {"
+ " \"bool\": {"
+ " \"should\": ["
+ " {"
+ " \"match\": {"
+ " \"message\": \"test 1\""
+ " }"
+ " }"
+ " ]"
+ " }"
+ " }"
+ " ,\"gas-filter\" :{"
+ " \"name\": \"SearchResultCypherFilter\","
+ " \"query\": \"MATCH (n) RETURN n.id as id\","
+ " \"exclude\": false,"
+ " \"protocol\": \"bolt\""
+ " }"
+ "}";
Search search = new Search.Builder(query)
// multiple index or types can be added.
.addIndex(INDEX_NAME)
.addType(TYPE_NAME)
.build();
SearchResult result = jestClient.execute(search);
assertEquals(100, result.getTotal().intValue());
}
private void createData() throws IOException {
for (int i = 0; i < 100; ++i) {
index(INDEX_NAME, TYPE_NAME, String.valueOf(i), document(String.valueOf(i)));
}
refresh();
assertHitCount(INDEX_NAME, TYPE_NAME, 100);
}
private void createIndices() {
Map<String, Object> settings1 = new HashMap<>();
settings1.put(INDEX_GA_ES_NEO4J_ENABLED, true);
settings1.put(INDEX_GA_ES_NEO4J_HOST, HTTP_URL);
settings1.put(INDEX_GA_ES_NEO4J_USER, NEO4J_USER);
settings1.put(INDEX_GA_ES_NEO4J_PWD, NEO4J_PASSWORD);
settings1.put(INDEX_GA_ES_NEO4J_BOLT_HOST, BOLT_URL);
createIndex(INDEX_NAME, settings1);
Map<String, Object> settings2 = new HashMap<>();
settings2.put(INDEX_GA_ES_NEO4J_ENABLED, false);
createIndex(DISABLED_INDEX_NAME, settings2);
}
private HashMap<String, Object> document(String id) {
HashMap<String, Object> doc = new HashMap<>();
doc.put("id", id);
doc.put("message", "test " + id);
doc.put("counter", Integer.valueOf(id));
return doc;
}
protected String executeCypher(String query) {
cypherEndPoint.executeCypher(query, new HashMap<String, Object>());
return "";
}
}
================================================
FILE: src/test/java/com/graphaware/es/gas/GraphAidedSearchIntegrationTest.java
================================================
/*
* Copyright (c) 2013-2016 GraphAware
*
* This file is part of the GraphAware Framework.
*
* GraphAware Framework is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of
* the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.graphaware.es.gas;
import io.searchbox.core.Search;
import io.searchbox.core.SearchResult;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.index.query.MatchQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHits;
import org.junit.Test;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.graphaware.es.gas.wrap.GraphAidedSearchActionListenerWrapper.INDEX_GA_ES_NEO4J_ENABLED;
import static com.graphaware.es.gas.wrap.GraphAidedSearchActionListenerWrapper.INDEX_GA_ES_NEO4J_HOST;
import static com.graphaware.es.gas.wrap.GraphAidedSearchActionListenerWrapper.INDEX_GA_ES_NEO4J_PWD;
import static com.graphaware.es.gas.wrap.GraphAidedSearchActionListenerWrapper.INDEX_GA_ES_NEO4J_USER;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class GraphAidedSearchIntegrationTest extends GraphAidedSearchTest {
private static final String INDEX_NAME = "test-index";
private static final String DISABLED_INDEX_NAME = "disabled-test-index";
private static final String NEO4J_HOSTNAME = "http://localhost:7474";
private static final String TYPE_NAME = "test_data";
@Override
public void setUp() throws Exception{
super.setUp();
createIndices();
createData();
}
@Override
protected HashMap<String, Object> clusterSettings() {
HashMap<String, Object> settings = new HashMap<>();
settings.put("script.search", "on");
settings.put("http.cors.enabled", true);
settings.put("http.cors.allow-origin", "*");
settings.put("index.number_of_shards", 3);
settings.put("index.number_of_replicas", 0);
settings.put("discovery.zen.ping.unicast.hosts","localhost:9301-9310");
settings.put("plugin.types", "com.graphaware.es.gas.GraphAidedSearchPlugin");
settings.put("index.unassigned.node_left.delayed_timeout", "0");
return settings;
}
// @Test
// public void testPluginSetup() {
// final GraphAidedSearch plugin = runner.getInstance(GraphAidedSearch.class);
// final IndexInfo indexInfo = plugin.getScriptInfo(INDEX_NAME);
// assertEquals(NEO4J_HOSTNAME, indexInfo.getNeo4jHost());
// assertTrue(indexInfo.isEnabled());
// }
@Test
public void testQueryWithoutPlugin() {
MatchQueryBuilder query = QueryBuilders.matchQuery("message", "test 1");
final SearchResponse searchResponse = client().prepareSearch(INDEX_NAME)
.setQuery(query)
.execute().actionGet();
final SearchHits hits = searchResponse.getHits();
assertEquals(100, hits.getTotalHits());
assertEquals(10, hits.hits().length);
assertEquals("1", hits.hits()[0].id());
}
@Test
public void testExtendeBaseBoostingQuery() throws IOException{
String query = "{"
+ " \"query\": {"
+ " \"bool\": {"
+ " \"should\": ["
+ " {"
+ " \"match\": {"
+ " \"message\": \"test 99\""
+ " }"
+ " }"
+ " ]"
+ " }"
+ " }"
+ " ,\"gas-booster\" :{"
+ " \"name\": \"SearchResultTestBooster\","
+ " \"target\": \"Durgan%20LLC\""
+ " }"
+ "}";
Search search = new Search.Builder(query)
// multiple index or types can be added.
.addIndex(INDEX_NAME)
.addType(TYPE_NAME)
.build();
SearchResult result = jestClient.execute(search);
assertEquals(100, result.getTotal().intValue());
List<SearchResult.Hit<JestMsgResult, Void>> hits = getHitsForResult(result);
assertEquals(10, hits.size());
float withoutBoosterMaxScore = getResultForDocWithMessage("test 99").getMaxScore();
assertEquals("test 99", hits.get(0).source.getMsg());
assertEquals("test 94", hits.get(1).source.getMsg());
assertEquals("test 91", hits.get(2).source.getMsg());
assertEquals("test 90", hits.get(3).source.getMsg());
assertEquals("test 88", hits.get(4).source.getMsg());
assertTrue(hits.get(0).score > hits.get(1).score);
assertTrue(hits.get(1).score > hits.get(2).score);
assertTrue(hits.get(2).score > hits.get(3).score);
assertTrue(hits.get(4).score > hits.get(5).score);
float expectedScore = withoutBoosterMaxScore * (Integer.parseInt(hits.get(0).source.getDocumentId()) * 1000);
assertEquals(expectedScore, result.getMaxScore(), 1);
}
@Test
public void testCypherFilterQueryWithExcludeFalse() throws IOException {
String query = "{"
+ " \"query\": {"
+ " \"bool\": {"
+ " \"should\": ["
+ " {"
+ " \"match\": {"
+ " \"message\": \"test 1\""
+ " }"
+ " }"
+ " ]"
+ " }"
+ " }"
+ " ,\"gas-filter\" :{"
+ " \"name\": \"CypherSearchResultTestFilter\"," +
" \"query\": \"MATCH (n) RETURN n\","
+ " \"exclude\": false"
+ " }"
+ "}";
Search search = new Search.Builder(query)
// multiple index or types can be added.
.addIndex(INDEX_NAME)
.addType(TYPE_NAME)
.build();
SearchResult result = jestClient.execute(search);
assertEquals(33, result.getTotal().intValue());
List<SearchResult.Hit<JestMsgResult, Void>> hits = getHitsForResult(result);
assertEquals(10, hits.size());
// assertEquals("test 36", hits.instantiate(0).source.getMsg());
// assertEquals(2.6, result.getMaxScore(), 0.1);
}
@Test
public void testCypherFilterWithInvalidSyntax() throws IOException {
String query = "{"
+ " \"query\": {"
+ " \"bool\": {"
+ " \"should\": ["
+ " {"
+ " \"match\": {"
+ " \"message\": \"test 1\""
+ " }"
+ " }"
+ " ]"
+ " }"
+ " }"
+ " ,\"gas-filter\" :{"
+ " \"name\": \"SearchResultCypherFilter\","
+ " \"exclude\": false," +
" \"query\": \"MATCH (n) RETURN (x)\""
+ " }"
+ "}";
Search search = new Search.Builder(query)
// multiple index or types can be added.
.addIndex(INDEX_NAME)
.addType(TYPE_NAME)
.build();
SearchResult result = jestClient.execute(search);
System.out.println(result.getJsonObject().toString());
assertTrue(result.getErrorMessage().contains("Cypher Execution Error"));
}
@Test
public void testCypherFilterQueryWithExcludeTrue() throws IOException {
String query = "{"
+ " \"query\": {"
+ " \"bool\": {"
+ " \"should\": ["
+ " {"
+ " \"match\": {"
+ " \"message\": \"test 1\""
+ " }"
+ " }"
+ " ]"
+ " }"
+ " }"
+ " ,\"gas-filter\" :{"
+ " \"name\": \"CypherSearchResultTestFilter\"," +
" \"query\": \"MATCH (n) RETURN n\","
+ " \"exclude\": true"
+ " }"
+ "}";
Search search = new Search.Builder(query)
// multiple index or types can be added.
.addIndex(INDEX_NAME)
.addType(TYPE_NAME)
.build();
SearchResult result = jestClient.execute(search);
System.out.println(result.getJsonObject().toString());
assertEquals(67, result.getTotal().intValue());
List<SearchResult.Hit<JestMsgResult, Void>> hits = getHitsForResult(result);
assertEquals(10, hits.size());
// assertEquals("test 35", hits.instantiate(0).source.getMsg());
// assertEquals(2.5, result.getMaxScore(), 0.1);
}
@Test
public void testCypherFilterWithFromAndSizeDifferentThanZero() throws IOException {
String query = "{"
+ "\"from\" : 5, \"size\" : 25,"
+ " \"query\": {"
+ " \"bool\": {"
+ " \"should\": ["
gitextract_nj6_eb0u/
├── .gitignore
├── .travis.yml
├── README.md
├── gpl.txt
├── pom.xml
└── src/
├── main/
│ ├── assemblies/
│ │ └── plugin.xml
│ ├── java/
│ │ └── com/
│ │ └── graphaware/
│ │ └── es/
│ │ └── gas/
│ │ ├── GraphAidedSearch.java
│ │ ├── GraphAidedSearchFilter.java
│ │ ├── GraphAidedSearchModule.java
│ │ ├── GraphAidedSearchPlugin.java
│ │ ├── annotation/
│ │ │ ├── SearchBooster.java
│ │ │ └── SearchFilter.java
│ │ ├── booster/
│ │ │ ├── SearchResultBooster.java
│ │ │ ├── SearchResultCypherBooster.java
│ │ │ ├── SearchResultExternalBooster.java
│ │ │ └── SearchResultNeo4jBooster.java
│ │ ├── cypher/
│ │ │ ├── CypherBoltHttpEndPoint.java
│ │ │ ├── CypherEndPoint.java
│ │ │ ├── CypherEndPointBuilder.java
│ │ │ ├── CypherHttpEndPoint.java
│ │ │ ├── CypherResult.java
│ │ │ ├── CypherSettingsReader.java
│ │ │ └── ResultRow.java
│ │ ├── domain/
│ │ │ ├── ClauseConstants.java
│ │ │ ├── ExternalResult.java
│ │ │ └── IndexInfo.java
│ │ ├── filter/
│ │ │ ├── SearchResultCypherFilter.java
│ │ │ └── SearchResultFilter.java
│ │ ├── modifier/
│ │ │ ├── PrivilegedSearchResultModifier.java
│ │ │ └── SearchResultModifier.java
│ │ ├── util/
│ │ │ ├── Instantiator.java
│ │ │ ├── NumberUtil.java
│ │ │ ├── ParamUtil.java
│ │ │ ├── PluginClassLoader.java
│ │ │ └── UrlUtil.java
│ │ └── wrap/
│ │ ├── ActionListenerWrapper.java
│ │ ├── CannotWrapException.java
│ │ ├── GraphAidedSearchActionListenerWrapper.java
│ │ └── WrappingActionListener.java
│ └── plugin-metadata/
│ ├── plugin-descriptor.properties
│ └── plugin-security.policy
└── test/
├── java/
│ └── com/
│ └── graphaware/
│ └── es/
│ └── gas/
│ ├── EmbeddedGraphDatabaseServerTest.java
│ ├── GraphAidedSearchFilterTest.java
│ ├── GraphAidedSearchIntegrationBoltTest.java
│ ├── GraphAidedSearchIntegrationTest.java
│ ├── GraphAidedSearchNeo4jIntegrationTest.java
│ ├── GraphAidedSearchTest.java
│ ├── JestMsgResult.java
│ ├── MockServerTest.java
│ ├── booster/
│ │ ├── GraphBoosterTest.java
│ │ ├── SearchResultCypherBoltBoosterTest.java
│ │ ├── SearchResultCypherBoosterTest.java
│ │ └── SearchResultNeo4jBoosterTest.java
│ ├── domain/
│ │ ├── CypherEndpointBoltTest.java
│ │ ├── CypherEndpointTest.java
│ │ ├── CypherEndpointUnitTest.java
│ │ ├── ExternalResultTest.java
│ │ ├── ExternalResultUnitTest.java
│ │ └── TestIndexInfo.java
│ ├── filter/
│ │ ├── GraphFilterTest.java
│ │ └── SearchResultCypherFilterTest.java
│ ├── stubs/
│ │ ├── CypherSearchResultTestBooster.java
│ │ ├── CypherSearchResultTestFilter.java
│ │ └── SearchResultTestBooster.java
│ └── util/
│ ├── ClauseConstantsTest.java
│ ├── NumberUtilTest.java
│ ├── TestHttpClient.java
│ └── UrlUtilTest.java
└── resources/
├── demo-data-reduced.cyp
├── demo-data.cyp
├── graphgen-test-data.cyp
├── neo4j-elasticsearch-reco.properties
├── neo4j-elasticsearch.properties
└── neo4j-server-es.properties
SYMBOL INDEX (423 symbols across 58 files)
FILE: src/main/java/com/graphaware/es/gas/GraphAidedSearch.java
class GraphAidedSearch (line 31) | public class GraphAidedSearch extends AbstractLifecycleComponent<GraphAi...
method GraphAidedSearch (line 36) | @Inject
method initializeFilters (line 46) | private void initializeFilters() {
method doStart (line 57) | @Override
method doStop (line 62) | @Override
method doClose (line 67) | @Override
FILE: src/main/java/com/graphaware/es/gas/GraphAidedSearchFilter.java
class GraphAidedSearchFilter (line 34) | public class GraphAidedSearchFilter extends AbstractComponent implements...
method GraphAidedSearchFilter (line 46) | @Inject
method setWrapper (line 53) | public void setWrapper(ActionListenerWrapper<?> wrapper) {
method order (line 57) | @Override
method apply (line 62) | @Override
method apply (line 75) | @Override
FILE: src/main/java/com/graphaware/es/gas/GraphAidedSearchModule.java
class GraphAidedSearchModule (line 20) | public class GraphAidedSearchModule extends AbstractModule {
method configure (line 22) | @Override
FILE: src/main/java/com/graphaware/es/gas/GraphAidedSearchPlugin.java
class GraphAidedSearchPlugin (line 29) | public class GraphAidedSearchPlugin extends Plugin {
method name (line 31) | @Override
method description (line 36) | @Override
method onModule (line 41) | public void onModule(final ActionModule module) {
method onModule (line 45) | public void onModule(final ClusterModule module) {
method nodeModules (line 52) | @Override
FILE: src/main/java/com/graphaware/es/gas/booster/SearchResultBooster.java
type SearchResultBooster (line 20) | public interface SearchResultBooster extends SearchResultModifier {
FILE: src/main/java/com/graphaware/es/gas/booster/SearchResultCypherBooster.java
class SearchResultCypherBooster (line 38) | @SearchBooster(name = "SearchResultCypherBooster")
method SearchResultCypherBooster (line 48) | public SearchResultCypherBooster(Settings settings, IndexInfo indexInf...
method extendedParseRequest (line 53) | @Override
method externalDoReorder (line 62) | @Override
method getExternalResults (line 68) | protected Map<String, ExternalResult> getExternalResults(Set<String> k...
method getParameters (line 79) | public HashMap<String, Object> getParameters(Set<String> resultKeySet) {
method getEndpoint (line 86) | public String getEndpoint(String serverUrl) {
method getScoreResultName (line 90) | public String getScoreResultName() {
method getIdResultName (line 94) | public String getIdResultName() {
method checkResultRow (line 98) | protected void checkResultRow(ResultRow resultRow) {
method dispatchInvalidResultException (line 107) | private void dispatchInvalidResultException(String missingKey) {
FILE: src/main/java/com/graphaware/es/gas/booster/SearchResultExternalBooster.java
class SearchResultExternalBooster (line 32) | public abstract class SearchResultExternalBooster extends CypherSettings...
method SearchResultExternalBooster (line 47) | public SearchResultExternalBooster(Settings settings, IndexInfo indexS...
method parseRequest (line 51) | @Override
method modify (line 69) | @Override
method composeScore (line 122) | protected float composeScore(float esScore, float extScore) {
method getSize (line 140) | public int getSize() {
method getFrom (line 144) | public int getFrom() {
method getMaxResultSize (line 148) | public int getMaxResultSize() {
method externalDoReorder (line 152) | protected abstract Map<String, ExternalResult> externalDoReorder(Set<S...
method extendedParseRequest (line 154) | protected void extendedParseRequest(Map<String, String> extParams) {
method validateOperator (line 158) | protected void validateOperator() {
method getComposeScoreOperator (line 173) | protected String getComposeScoreOperator() {
FILE: src/main/java/com/graphaware/es/gas/booster/SearchResultNeo4jBooster.java
class SearchResultNeo4jBooster (line 47) | @SearchBooster(name = "SearchResultNeo4jBooster")
method SearchResultNeo4jBooster (line 58) | public SearchResultNeo4jBooster(Settings settings, IndexInfo indexSett...
method externalDoReorder (line 63) | @Override
method getReorderedResults (line 73) | public Map<String, ExternalResult> getReorderedResults(List<ExternalRe...
method getExternalResults (line 82) | public List<ExternalResult> getExternalResults(Set<String> keySet) {
method setHeader (line 112) | private void setHeader(WebResource.Builder resBuilder) {
method extendedParseRequest (line 122) | @Override
method getParameters (line 129) | public MultivaluedMap getParameters(Set<String> keySet) {
method getTargetId (line 138) | protected String getTargetId() {
method getKeyProperty (line 142) | public String getKeyProperty() {
method getEndpoint (line 146) | public String getEndpoint() {
method implodeKeySet (line 152) | public String implodeKeySet(Set<String> keySet) {
FILE: src/main/java/com/graphaware/es/gas/cypher/CypherBoltHttpEndPoint.java
class CypherBoltHttpEndPoint (line 32) | public class CypherBoltHttpEndPoint extends CypherEndPoint {
method CypherBoltHttpEndPoint (line 36) | CypherBoltHttpEndPoint(Settings settings, String neo4jUrl, String neo4...
method executeCypher (line 41) | public CypherResult executeCypher(String cypherQuery) {
method executeCypher (line 45) | @Override
method buildResult (line 70) | private CypherResult buildResult(StatementResult response) {
method executeCypher (line 83) | @Override
FILE: src/main/java/com/graphaware/es/gas/cypher/CypherEndPoint.java
class CypherEndPoint (line 24) | public abstract class CypherEndPoint {
method CypherEndPoint (line 32) | public CypherEndPoint(Settings settings, String neo4jHost) {
method CypherEndPoint (line 36) | public CypherEndPoint(Settings settings, String neo4jHost, String neo4...
method getNeo4jPassword (line 47) | public String getNeo4jPassword() {
method getNeo4jUsername (line 51) | public String getNeo4jUsername() {
method getNeo4jHost (line 55) | public String getNeo4jHost() {
method executeCypher (line 59) | public abstract CypherResult executeCypher(String query, HashMap<Strin...
method executeCypher (line 61) | public abstract CypherResult executeCypher(HashMap<String, String> hea...
FILE: src/main/java/com/graphaware/es/gas/cypher/CypherEndPointBuilder.java
class CypherEndPointBuilder (line 20) | public class CypherEndPointBuilder {
method CypherEndPointBuilder (line 30) | public CypherEndPointBuilder(CypherEndPointType protocol) {
method CypherEndPointBuilder (line 34) | public CypherEndPointBuilder(String protocol) {
method settings (line 39) | public CypherEndPointBuilder settings(Settings settings) {
method neo4jHostname (line 44) | public CypherEndPointBuilder neo4jHostname(String neo4jHost) {
method neo4jBoltHostname (line 49) | public CypherEndPointBuilder neo4jBoltHostname(String neo4jBoltHost) {
method username (line 54) | public CypherEndPointBuilder username(String neo4jUsername) {
method password (line 59) | public CypherEndPointBuilder password(String neo4jPassword) {
method encryption (line 64) | public CypherEndPointBuilder encryption(boolean encryption) {
method build (line 69) | public CypherEndPoint build() {
method checkNeo4jHost (line 88) | private void checkNeo4jHost() {
type CypherEndPointType (line 93) | public enum CypherEndPointType {
method CypherEndPointType (line 99) | CypherEndPointType(String name) {
method getName (line 103) | public String getName() {
method getEnum (line 107) | public static CypherEndPointType getEnum(String value) {
FILE: src/main/java/com/graphaware/es/gas/cypher/CypherHttpEndPoint.java
class CypherHttpEndPoint (line 35) | public class CypherHttpEndPoint extends CypherEndPoint {
method CypherHttpEndPoint (line 48) | public CypherHttpEndPoint(Settings settings, String neo4jUrl, String n...
method buildCypherQuery (line 56) | public String buildCypherQuery(String cypherQuery) {
method executeCypher (line 60) | @Override
method executeCypher (line 67) | @Override
method buildCypherResult (line 77) | public CypherResult buildCypherResult(Map<String, Object> response) {
method buildCypherQuery (line 101) | public String buildCypherQuery(String cypherQuery, Map<String, Object>...
method post (line 117) | public Map<String, Object> post(String url, HashMap<String, String> he...
method checkErrors (line 156) | private void checkErrors(Map<String, Object> results) {
FILE: src/main/java/com/graphaware/es/gas/cypher/CypherResult.java
class CypherResult (line 21) | public class CypherResult {
method addRow (line 25) | public void addRow(ResultRow resultRow) {
method getRows (line 29) | public List<ResultRow> getRows() {
FILE: src/main/java/com/graphaware/es/gas/cypher/CypherSettingsReader.java
class CypherSettingsReader (line 21) | public class CypherSettingsReader {
method CypherSettingsReader (line 30) | public CypherSettingsReader(Settings settings, IndexInfo indexSettings) {
method createCypherEndPoint (line 40) | protected CypherEndPoint createCypherEndPoint(String protocol, Setting...
method getNeo4jHost (line 51) | public String getNeo4jHost() {
method getNeo4jUsername (line 55) | public String getNeo4jUsername() {
method getNeo4jPassword (line 59) | public String getNeo4jPassword() {
method getMaxResultWindow (line 63) | public int getMaxResultWindow() {
method getSettings (line 67) | public Settings getSettings() {
method isSecureBolt (line 71) | public boolean isSecureBolt() {
method getNeo4jBoltHost (line 75) | public String getNeo4jBoltHost() {
FILE: src/main/java/com/graphaware/es/gas/cypher/ResultRow.java
class ResultRow (line 21) | public class ResultRow {
method add (line 25) | public void add(String columnKey, Object item) {
method get (line 29) | public Object get(String columnKey) {
method getValues (line 33) | public Map<String, Object> getValues() {
FILE: src/main/java/com/graphaware/es/gas/domain/ClauseConstants.java
class ClauseConstants (line 19) | public final class ClauseConstants {
method ClauseConstants (line 48) | private ClauseConstants() {
FILE: src/main/java/com/graphaware/es/gas/domain/ExternalResult.java
class ExternalResult (line 18) | public class ExternalResult {
method ExternalResult (line 25) | public ExternalResult() {
method ExternalResult (line 28) | public ExternalResult(String objectId, float score) {
method getNodeId (line 33) | public long getNodeId() {
method setNodeId (line 37) | public void setNodeId(long nodeId) {
method getObjectId (line 41) | public String getObjectId() {
method setObjectId (line 45) | public void setObjectId(String uuid) {
method getScore (line 57) | public float getScore() {
method setScore (line 61) | public void setScore(float score) {
FILE: src/main/java/com/graphaware/es/gas/domain/IndexInfo.java
class IndexInfo (line 18) | public class IndexInfo {
method IndexInfo (line 31) | IndexInfo() {
method IndexInfo (line 38) | public IndexInfo(final String hostname, final String username, final S...
method IndexInfo (line 42) | public IndexInfo(final String hostname, final String boltHostname, fin...
method IndexInfo (line 46) | public IndexInfo(final String hostname, final String boltHostname, fin...
method IndexInfo (line 52) | public IndexInfo(final String hostname, boolean enabled, int maxResult...
method IndexInfo (line 56) | public IndexInfo(final String hostname, final String boltHostname, boo...
method getNeo4jHost (line 63) | public String getNeo4jHost() {
method isEnabled (line 67) | public boolean isEnabled() {
method getMaxResultWindow (line 71) | public int getMaxResultWindow() {
method toString (line 75) | @Override
method getNeo4jUsername (line 85) | public String getNeo4jUsername() {
method getNeo4jPassword (line 89) | public String getNeo4jPassword() {
method getNeo4jBoltHost (line 93) | public String getNeo4jBoltHost() {
method isSecureBolt (line 97) | public boolean isSecureBolt() {
FILE: src/main/java/com/graphaware/es/gas/filter/SearchResultCypherFilter.java
class SearchResultCypherFilter (line 39) | @SearchFilter(name = "SearchResultCypherFilter")
method SearchResultCypherFilter (line 59) | public SearchResultCypherFilter(Settings settings, IndexInfo indexSett...
method parseRequest (line 63) | @Override
method modify (line 85) | @Override
method getFilteredItems (line 131) | protected Set<String> getFilteredItems() {
method getCypherResult (line 142) | protected CypherResult getCypherResult() {
method getFilteredItem (line 146) | protected String getFilteredItem(ResultRow resultRow) {
method getSize (line 154) | public int getSize() {
method getFrom (line 158) | public int getFrom() {
method getIdResultName (line 162) | public String getIdResultName() {
method getIdentifier (line 166) | private static String getIdentifier(Object objectId) {
FILE: src/main/java/com/graphaware/es/gas/filter/SearchResultFilter.java
type SearchResultFilter (line 21) | public interface SearchResultFilter extends SearchResultModifier {
FILE: src/main/java/com/graphaware/es/gas/modifier/PrivilegedSearchResultModifier.java
class PrivilegedSearchResultModifier (line 25) | public class PrivilegedSearchResultModifier implements SearchResultModif...
method PrivilegedSearchResultModifier (line 29) | public PrivilegedSearchResultModifier(SearchResultModifier delegate) {
method modify (line 33) | @Override
method parseRequest (line 43) | @Override
FILE: src/main/java/com/graphaware/es/gas/modifier/SearchResultModifier.java
type SearchResultModifier (line 23) | public interface SearchResultModifier {
method modify (line 25) | InternalSearchHits modify(final InternalSearchHits hits);
method parseRequest (line 27) | void parseRequest(Map<String, Object> sourceAsMap);
FILE: src/main/java/com/graphaware/es/gas/util/Instantiator.java
class Instantiator (line 38) | public class Instantiator {
method Instantiator (line 45) | public Instantiator(Settings settings) {
method instantiate (line 51) | @SuppressWarnings("unchecked")
method instantiatePrivileged (line 75) | private <T extends SearchResultModifier> T instantiatePrivileged(final...
method instantiate (line 83) | private <T extends SearchResultModifier> T instantiate(String name, In...
method loadCachedClasses (line 105) | private <T extends SearchResultModifier> Map<String, Class<T>> loadCac...
method loadClasses (line 117) | private <T> Map<String, Class<T>> loadClasses(Class<T> clazz, Class<? ...
FILE: src/main/java/com/graphaware/es/gas/util/NumberUtil.java
class NumberUtil (line 18) | public final class NumberUtil {
method getInt (line 20) | public static int getInt(final Object value, final int defaultValue) {
method getFloat (line 29) | public static float getFloat(final Object value) {
method NumberUtil (line 39) | private NumberUtil() {
FILE: src/main/java/com/graphaware/es/gas/util/ParamUtil.java
class ParamUtil (line 21) | public final class ParamUtil {
method extractParameter (line 23) | public static <T> T extractParameter(String name, Map<String, T> param...
method extractParameter (line 33) | public static <T> T extractParameter(String name, Map<String, T> param...
method ParamUtil (line 38) | private ParamUtil() {
FILE: src/main/java/com/graphaware/es/gas/util/PluginClassLoader.java
class PluginClassLoader (line 26) | public final class PluginClassLoader {
method loadClass (line 30) | public static <T, A extends Annotation> Map<String, Class<T>> loadClas...
method loadClassByAnnotation (line 34) | private static <T, A extends Annotation> Map<String, Class<T>> loadCla...
method loadReflections (line 46) | private static void loadReflections(final String packagePath) {
method PluginClassLoader (line 55) | private PluginClassLoader() {
FILE: src/main/java/com/graphaware/es/gas/util/UrlUtil.java
class UrlUtil (line 21) | public class UrlUtil {
method buildUrlFromParts (line 23) | public static String buildUrlFromParts(String... parts) {
method UrlUtil (line 43) | private UrlUtil() {
method getAuthorizationHeaderValue (line 46) | public static String getAuthorizationHeaderValue(String username, Stri...
FILE: src/main/java/com/graphaware/es/gas/wrap/ActionListenerWrapper.java
type ActionListenerWrapper (line 23) | public interface ActionListenerWrapper<T extends StatusToXContent> {
method wrap (line 25) | ActionListener<T> wrap(final SearchRequest request, final ActionListen...
FILE: src/main/java/com/graphaware/es/gas/wrap/CannotWrapException.java
class CannotWrapException (line 19) | public class CannotWrapException extends Exception {
method CannotWrapException (line 21) | public CannotWrapException(String message) {
FILE: src/main/java/com/graphaware/es/gas/wrap/GraphAidedSearchActionListenerWrapper.java
class GraphAidedSearchActionListenerWrapper (line 55) | public class GraphAidedSearchActionListenerWrapper implements ActionList...
method GraphAidedSearchActionListenerWrapper (line 80) | public GraphAidedSearchActionListenerWrapper(Settings settings, Cluste...
method wrap (line 90) | @Override
method checkCorrectType (line 116) | private void checkCorrectType(SearchRequest request) throws CannotWrap...
method checkScroll (line 127) | private void checkScroll(SearchRequest request) throws CannotWrapExcep...
method checkNotAlreadyWrapped (line 133) | private void checkNotAlreadyWrapped(SearchRequest request) throws Cann...
method checkSource (line 140) | private void checkSource(SearchRequest request) throws CannotWrapExcep...
method checkIndex (line 150) | private void checkIndex(SearchRequest request) throws CannotWrapExcept...
method warnIfQueryBinary (line 157) | private void warnIfQueryBinary(Map<String, Object> sourceAsMap) {
method checkSizeAndFrom (line 164) | private void checkSizeAndFrom(int size, int from) throws CannotWrapExc...
method produceModifiers (line 170) | private List<SearchResultModifier> produceModifiers(IndexInfo scriptIn...
method buildBytes (line 190) | private BytesReference buildBytes(Map<String, Object> source) {
method createActionListener (line 203) | private ActionListener<SearchResponse> createActionListener(final Sear...
method getScriptInfo (line 217) | private IndexInfo getScriptInfo(final String index) {
FILE: src/main/java/com/graphaware/es/gas/wrap/WrappingActionListener.java
class WrappingActionListener (line 47) | public class WrappingActionListener implements ActionListener<SearchResp...
method WrappingActionListener (line 55) | public WrappingActionListener(ActionListener<SearchResponse> wrapped, ...
method onResponse (line 63) | @Override
method onFailure (line 84) | @Override
method handleResponse (line 89) | private SearchResponse handleResponse(final SearchResponse response, f...
method readHeaders (line 111) | private Map<String, Object> readHeaders(ChannelBufferStreamInput in) t...
method readHits (line 123) | private InternalSearchHits readHits(ChannelBufferStreamInput in) throw...
method modifyHits (line 131) | private InternalSearchHits modifyHits(List<SearchResultModifier> modif...
method sortResults (line 140) | private InternalSearchHit[] sortResults(InternalSearchHits hits) {
method readAggregations (line 162) | private InternalAggregations readAggregations(ChannelBufferStreamInput...
method readSuggestions (line 174) | private Suggest readSuggestions(ChannelBufferStreamInput in) throws IO...
method readInternalProfileShardResults (line 186) | private InternalProfileShardResults readInternalProfileShardResults(Ch...
method createNewResponse (line 200) | private SearchResponse createNewResponse(long startTime, ChannelBuffer...
method copyHeaders (line 224) | private void copyHeaders(Map<String, Object> headers, SearchResponse n...
method logTime (line 232) | private void logTime(SearchResponse response, long startTime) {
FILE: src/test/java/com/graphaware/es/gas/EmbeddedGraphDatabaseServerTest.java
class EmbeddedGraphDatabaseServerTest (line 19) | public class EmbeddedGraphDatabaseServerTest {
method EmbeddedGraphDatabaseServerTest (line 22) | public EmbeddedGraphDatabaseServerTest() {
method setUpClass (line 25) | @BeforeClass
method tearDownClass (line 29) | @AfterClass
method setUp (line 33) | @Before
method tearDown (line 39) | @After
method someTest (line 44) | @Test
FILE: src/test/java/com/graphaware/es/gas/GraphAidedSearchFilterTest.java
class GraphAidedSearchFilterTest (line 8) | public class GraphAidedSearchFilterTest {
method testDefaultFilterOrder (line 10) | @Test
method testCustomFilterOrder (line 17) | @Test
FILE: src/test/java/com/graphaware/es/gas/GraphAidedSearchIntegrationBoltTest.java
class GraphAidedSearchIntegrationBoltTest (line 33) | public class GraphAidedSearchIntegrationBoltTest extends GraphAidedSearc...
method setUp (line 43) | @Override
method createNeo4jServer (line 51) | protected void createNeo4jServer() throws IOException {
method clusterSettings (line 64) | @Override
method testCypherFilterWithGraphAndBolt (line 79) | @Test
method createData (line 112) | private void createData() throws IOException {
method createIndices (line 120) | private void createIndices() {
method document (line 134) | private HashMap<String, Object> document(String id) {
method executeCypher (line 143) | protected String executeCypher(String query) {
FILE: src/test/java/com/graphaware/es/gas/GraphAidedSearchIntegrationTest.java
class GraphAidedSearchIntegrationTest (line 39) | public class GraphAidedSearchIntegrationTest extends GraphAidedSearchTest {
method setUp (line 46) | @Override
method clusterSettings (line 54) | @Override
method testQueryWithoutPlugin (line 77) | @Test
method testExtendeBaseBoostingQuery (line 89) | @Test
method testCypherFilterQueryWithExcludeFalse (line 133) | @Test
method testCypherFilterWithInvalidSyntax (line 169) | @Test
method testCypherFilterQueryWithExcludeTrue (line 201) | @Test
method testCypherFilterWithFromAndSizeDifferentThanZero (line 238) | @Test
method testCypherFilterWithGraph (line 276) | @Test
method testCypherBooster (line 308) | @Test
method testCypherBoosterWithInvalidSyntax (line 348) | @Test
method testCypherBoosterWithReplace (line 380) | @Test
method testCypherBoosterWithCustomOperator (line 422) | @Test
method createData (line 462) | private void createData() throws IOException {
method createIndices (line 470) | private void createIndices() {
method document (line 483) | private HashMap<String, Object> document(String id) {
method getResultForDocWithMessage (line 492) | private SearchResult getResultForDocWithMessage(String message) throws...
method getHitsForResult (line 516) | private List<SearchResult.Hit<JestMsgResult, Void>> getHitsForResult(S...
FILE: src/test/java/com/graphaware/es/gas/GraphAidedSearchNeo4jIntegrationTest.java
class GraphAidedSearchNeo4jIntegrationTest (line 39) | public class GraphAidedSearchNeo4jIntegrationTest extends GraphAidedSear...
method setUp (line 50) | @Override
method clusterSettings (line 59) | @Override
method stopMock (line 74) | @After
method createMockIndex (line 79) | private void createMockIndex() {
method testSearchResultNeo4jBooster (line 88) | @Test
method testSearchResultNeo4jBoosterAuth (line 126) | @Test
method testSearchResultNeo4jBoosterAuthFail (line 164) | @Test
method testSearchResultNeo4jBoosterSubtract (line 197) | @Test
method testSearchResultNeo4jBoosterDivide (line 237) | @Test
method testSearchResultNeo4jBoosterReplace (line 276) | @Test
method testSearchResultNeo4jBoosterFrom (line 313) | @Test
method setMockResponse (line 353) | private void setMockResponse() {
method setMockAuthResponse (line 384) | private void setMockAuthResponse(String auth) {
method createData (line 418) | private void createData() throws IOException {
method document (line 426) | private HashMap<String, Object> document(String id) {
method getResultForDocWithMessage (line 435) | private SearchResult getResultForDocWithMessage(String message) throws...
method getResultForDocWithMessage (line 459) | private float getResultForDocWithMessage(String message, String value)...
method getResult (line 485) | private float getResult(SearchResult results, String value) {
method getHitsForResult (line 495) | private List<SearchResult.Hit<JestMsgResult, Void>> getHitsForResult(S...
FILE: src/test/java/com/graphaware/es/gas/GraphAidedSearchTest.java
class GraphAidedSearchTest (line 44) | public abstract class GraphAidedSearchTest {
method setUp (line 61) | @Before
method createCluster (line 70) | protected void createCluster() {
method createJestClient (line 83) | protected void createJestClient() {
method createNeo4jServer (line 92) | protected void createNeo4jServer() throws IOException {
method cypherFile (line 98) | protected String cypherFile() {
method createIndex (line 102) | protected CreateIndexResponse createIndex(String indexName) {
method createIndex (line 106) | protected CreateIndexResponse createIndex(String indexName, Map<String...
method numberOfNodes (line 117) | protected int numberOfNodes() {
method clusterName (line 121) | protected String clusterName() {
method clusterSettings (line 125) | protected HashMap<String, Object> clusterSettings() {
method clientHost (line 129) | protected String clientHost() {
method clientPort (line 133) | protected int clientPort() {
method getConnection (line 137) | private String getConnection() {
method index (line 141) | protected IndexResponse index(String indexName, String type, String id...
method index (line 145) | protected IndexResponse index(String indexName, String type, String id...
method assertHitCount (line 152) | protected void assertHitCount(String indexName, String typeName, int e...
method refresh (line 156) | protected final void refresh() {
method client (line 160) | protected final Client client() {
method emptyDB (line 164) | protected void emptyDB() {
method changePassword (line 168) | protected void changePassword() {
method getAuthorizationHeaders (line 177) | protected HashMap<String, String> getAuthorizationHeaders(String passw...
method executeCypher (line 189) | protected String executeCypher(String query) {
method tearDown (line 193) | @After
FILE: src/test/java/com/graphaware/es/gas/JestMsgResult.java
class JestMsgResult (line 20) | public class JestMsgResult
method getDocumentId (line 28) | public String getDocumentId()
method getMsg (line 32) | public String getMsg()
method setMessage (line 36) | public void setMessage(String name)
FILE: src/test/java/com/graphaware/es/gas/MockServerTest.java
class MockServerTest (line 28) | public class MockServerTest {
method startMockServer (line 32) | @Before
method stopProxy (line 37) | @After
method testGetExternalResults (line 44) | @Test
FILE: src/test/java/com/graphaware/es/gas/booster/GraphBoosterTest.java
class GraphBoosterTest (line 30) | public class GraphBoosterTest {
method setUp (line 34) | @Before
method testComposeScoreIsSetByDefault (line 42) | @Test
method testComposerScoreOperatorCanBeCustomized (line 47) | @Test
method testExceptionIsThrownWhenQueryParameterIsMissing (line 73) | @Test
method getBoosterSourceMap (line 86) | private HashMap<String, Object> getBoosterSourceMap(String operator) {
FILE: src/test/java/com/graphaware/es/gas/booster/SearchResultCypherBoltBoosterTest.java
class SearchResultCypherBoltBoosterTest (line 22) | public class SearchResultCypherBoltBoosterTest extends SearchResultCyphe...
method createNeo4jServer (line 28) | protected void createNeo4jServer() throws IOException {
method getDefaultMap (line 41) | protected HashMap<String, Object> getDefaultMap(String query) {
method getBooster (line 51) | protected SearchResultCypherBooster getBooster() {
method executeCypher (line 58) | protected String executeCypher(String query) {
FILE: src/test/java/com/graphaware/es/gas/booster/SearchResultCypherBoosterTest.java
class SearchResultCypherBoosterTest (line 20) | public class SearchResultCypherBoosterTest extends GraphAidedSearchTest {
method testDefaultBoosterSettings (line 22) | @Test
method testGetExternalResultsWhenKeySetIsEmpty (line 32) | @Test
method testExternalResultsAreReturned (line 41) | @Test
method testExternalResultsAreReturnedWithCustomIdentifierAndScoreName (line 55) | @Test
method testExceptionIsThrownWhenScoreResultNameIsNotReturned (line 72) | @Test
method testExceptionIsThrownWhenIdResultNameIsNotPresent (line 91) | @Test
method testGetParameters (line 108) | @Test
method getDefaultMap (line 123) | private HashMap<String, Object> getDefaultMap() {
method getDefaultMap (line 127) | private HashMap<String, Object> getDefaultMap(String query) {
method getBooster (line 136) | private SearchResultCypherBooster getBooster() {
method testExternalResultsIdsUsage (line 143) | @Test
FILE: src/test/java/com/graphaware/es/gas/booster/SearchResultNeo4jBoosterTest.java
class SearchResultNeo4jBoosterTest (line 23) | public class SearchResultNeo4jBoosterTest {
method startMockServer (line 27) | @Before
method stopProxy (line 32) | @After
method testNewInstance (line 37) | @Test
method testExtendedParseRequest (line 43) | @Test
method testGetReorderedResults (line 57) | @Test
method testExternalDoReorder (line 70) | @Test
method testGetExternalResults (line 89) | @Test
method testRestUrlBuilder (line 134) | @Test
method testBuildParameters (line 148) | @Test
method testImplodeKeySet (line 162) | @Test
method getDefaultMap (line 173) | private HashMap<String, Object> getDefaultMap() {
method getBooster (line 182) | private SearchResultNeo4jBooster getBooster() {
method getTestBooster (line 189) | private SearchResultNeo4jBooster getTestBooster() {
method getMockBooster (line 196) | private SearchResultNeo4jBooster getMockBooster() {
class SearchResultNeo4jBoostertest (line 203) | @SearchBooster(name = "SearchResultNeo4jBoostertest")
method SearchResultNeo4jBoostertest (line 206) | public SearchResultNeo4jBoostertest(Settings settings, IndexInfo ind...
method getExternalResults (line 210) | public List<ExternalResult> getExternalResults(Set<String> keySet) {
FILE: src/test/java/com/graphaware/es/gas/domain/CypherEndpointBoltTest.java
class CypherEndpointBoltTest (line 20) | public class CypherEndpointBoltTest {
method setUp (line 32) | @Before
method clear (line 46) | @After
method deleteDefaultKnownCertFileIfExists (line 51) | public static void deleteDefaultKnownCertFileIfExists() {
method testExecuteCypher (line 57) | @Test
method tearDown (line 71) | @After
FILE: src/test/java/com/graphaware/es/gas/domain/CypherEndpointTest.java
class CypherEndpointTest (line 22) | public class CypherEndpointTest {
method setUp (line 34) | @Before
method testExecuteCypher (line 48) | @Test
method changePassword (line 62) | private void changePassword() {
method getHeaders (line 71) | private HashMap<String, String> getHeaders(String user, String passwor...
method getJsonBody (line 83) | private String getJsonBody(String query) throws Exception {
method tearDown (line 94) | @After
FILE: src/test/java/com/graphaware/es/gas/domain/CypherEndpointUnitTest.java
class CypherEndpointUnitTest (line 16) | public class CypherEndpointUnitTest {
method setUp (line 24) | @Before
method testBuildCypherQuery (line 34) | @Test
method testBuildQueryWithParameters (line 41) | @Test
FILE: src/test/java/com/graphaware/es/gas/domain/ExternalResultTest.java
class ExternalResultTest (line 7) | public class ExternalResultTest {
method testNewInstance (line 9) | @Test
FILE: src/test/java/com/graphaware/es/gas/domain/ExternalResultUnitTest.java
class ExternalResultUnitTest (line 7) | public class ExternalResultUnitTest {
method testNewInstance (line 9) | @Test
method testMethods (line 17) | @Test
FILE: src/test/java/com/graphaware/es/gas/domain/TestIndexInfo.java
class TestIndexInfo (line 19) | public class TestIndexInfo extends IndexInfo {
method newInstance (line 21) | public static IndexInfo newInstance() {
FILE: src/test/java/com/graphaware/es/gas/filter/GraphFilterTest.java
class GraphFilterTest (line 29) | public class GraphFilterTest {
method setUp (line 33) | @Before
method testQueryParameterIsMandatory (line 40) | @Test
FILE: src/test/java/com/graphaware/es/gas/filter/SearchResultCypherFilterTest.java
class SearchResultCypherFilterTest (line 13) | public class SearchResultCypherFilterTest {
method testSizeIsParsedFromRequest (line 15) | @Test
method testSizeHasDefault (line 24) | @Test
method testFromIsParsedFromRequest (line 32) | @Test
method testFromHasDefault (line 41) | @Test
method testIdResultNameHasDefault (line 49) | @Test
method testIdResultNameCanBeCustomized (line 55) | @Test
method getDefaultMap (line 65) | private HashMap<String, Object> getDefaultMap() {
method getFilter (line 74) | private SearchResultCypherFilter getFilter() {
FILE: src/test/java/com/graphaware/es/gas/stubs/CypherSearchResultTestBooster.java
class CypherSearchResultTestBooster (line 29) | @SearchBooster(name = "CypherSearchResultTestBooster")
method CypherSearchResultTestBooster (line 32) | public CypherSearchResultTestBooster(Settings settings, IndexInfo inde...
method getExternalResults (line 36) | @Override
FILE: src/test/java/com/graphaware/es/gas/stubs/CypherSearchResultTestFilter.java
class CypherSearchResultTestFilter (line 27) | @SearchFilter(name = "CypherSearchResultTestFilter")
method CypherSearchResultTestFilter (line 30) | public CypherSearchResultTestFilter(Settings settings, IndexInfo index...
method getFilteredItems (line 34) | @Override
FILE: src/test/java/com/graphaware/es/gas/stubs/SearchResultTestBooster.java
class SearchResultTestBooster (line 29) | @SearchBooster(name = "SearchResultTestBooster")
method SearchResultTestBooster (line 33) | public SearchResultTestBooster(Settings settings, IndexInfo indexSetti...
method externalDoReorder (line 37) | @Override
FILE: src/test/java/com/graphaware/es/gas/util/ClauseConstantsTest.java
class ClauseConstantsTest (line 14) | public class ClauseConstantsTest {
method testConstants (line 16) | @Test
method assertUtilityClassWellDefined (line 31) | public static void assertUtilityClassWellDefined(Class clazz)
FILE: src/test/java/com/graphaware/es/gas/util/NumberUtilTest.java
class NumberUtilTest (line 7) | public class NumberUtilTest {
method testDefaultValueIsReturned (line 11) | @Test
method testIntegersAreReturnedWhenIntegersGiven (line 16) | @Test
method testIntegerIsReturnedWhenFloatIsGiven (line 21) | @Test
method testIntegerIsReturnedWhenStringIsGiven (line 26) | @Test
method testIntegerIsReturnedAsFloat (line 31) | @Test
method testFloatIsReturnedAsFloat (line 36) | @Test
method testStringIsReturnedAsFloat (line 41) | @Test
FILE: src/test/java/com/graphaware/es/gas/util/TestHttpClient.java
class TestHttpClient (line 27) | public class TestHttpClient {
method TestHttpClient (line 36) | public TestHttpClient() {
method TestHttpClient (line 45) | public TestHttpClient(HttpClientBuilder builder) {
method get (line 56) | public String get(String url, final int expectedStatusCode) {
method get (line 68) | public String get(String url, Map<String, String> headers, final int e...
method post (line 83) | public String post(String url, final int expectedStatusCode) {
method post (line 95) | public String post(String url, String json, final int expectedStatusCo...
method post (line 108) | public String post(String url, String json, Map<String, String> header...
method post (line 122) | public String post(String url, String json, Map<String, String> header...
method put (line 141) | public String put(String url, final int expectedStatusCode) {
method put (line 153) | public String put(String url, String json, final int expectedStatusCod...
method put (line 166) | public String put(String url, String json, Map<String, String> headers...
method delete (line 184) | public String delete(String url, final int expectedStatusCode) {
method delete (line 196) | public String delete(String url, Map<String, String> headers, final in...
method method (line 211) | public String method(HttpRequestBase method, final int expectedStatusC...
method executeCypher (line 232) | public String executeCypher(String serverUrl, String... cypherStatemen...
method executeCypher (line 244) | public String executeCypher(String serverUrl, Map<String, String> head...
method setHeaders (line 260) | protected void setHeaders(HttpRequestBase method, Map<String, String> ...
method setParams (line 270) | protected void setParams(HttpRequestBase method, Map<String, String> p...
method responseHandler (line 289) | protected ResponseHandler<String> responseHandler(final int expectedSt...
method close (line 303) | public void close() {
FILE: src/test/java/com/graphaware/es/gas/util/UrlUtilTest.java
class UrlUtilTest (line 7) | public class UrlUtilTest {
method buildEndpointTest (line 9) | @Test
Condensed preview — 74 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,214K chars).
[
{
"path": ".gitignore",
"chars": 1746,
"preview": "# Created by https://www.gitignore.io\n\n### Project ###\ndata/\n\n### Intellij ###\n# Covers JetBrains IDEs: IntelliJ, RubyMi"
},
{
"path": ".travis.yml",
"chars": 386,
"preview": "language: java\n\nbefore_install:\n - sudo apt-get update > /dev/null\n \njdk:\n - oraclejdk8\n - oraclejdk7\n\nbranches:"
},
{
"path": "README.md",
"chars": 16378,
"preview": "# GraphAware Graph-Aided Search - RETIRED\n\n## GraphAware Graph-Aided Search Has Been Retired\nAs of May 2021, this [repos"
},
{
"path": "gpl.txt",
"chars": 35147,
"preview": " GNU GENERAL PUBLIC LICENSE\n Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
},
{
"path": "pom.xml",
"chars": 15840,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<!--\n~ Copyright (c) 2013-2016 GraphAware\n~\n~ This file is part of the GraphAwar"
},
{
"path": "src/main/assemblies/plugin.xml",
"chars": 1604,
"preview": "<?xml version=\"1.0\"?>\n<!--\n ~ Copyright (c) 2013-2016 GraphAware\n ~\n ~ This file is part of the GraphAware Framework."
},
{
"path": "src/main/java/com/graphaware/es/gas/GraphAidedSearch.java",
"chars": 2521,
"preview": "\n/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framewor"
},
{
"path": "src/main/java/com/graphaware/es/gas/GraphAidedSearchFilter.java",
"chars": 3076,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/GraphAidedSearchModule.java",
"chars": 1007,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/GraphAidedSearchPlugin.java",
"chars": 2093,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/annotation/SearchBooster.java",
"chars": 1068,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/annotation/SearchFilter.java",
"chars": 1067,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/booster/SearchResultBooster.java",
"chars": 917,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/booster/SearchResultCypherBooster.java",
"chars": 4562,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/booster/SearchResultExternalBooster.java",
"chars": 6459,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/booster/SearchResultNeo4jBooster.java",
"chars": 6219,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/cypher/CypherBoltHttpEndPoint.java",
"chars": 3592,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/cypher/CypherEndPoint.java",
"chars": 2252,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/cypher/CypherEndPointBuilder.java",
"chars": 3596,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/cypher/CypherHttpEndPoint.java",
"chars": 6811,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/cypher/CypherResult.java",
"chars": 1070,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/cypher/CypherSettingsReader.java",
"chars": 2647,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/cypher/ResultRow.java",
"chars": 1174,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/domain/ClauseConstants.java",
"chars": 2016,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/domain/ExternalResult.java",
"chars": 2082,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/domain/IndexInfo.java",
"chars": 3463,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/filter/SearchResultCypherFilter.java",
"chars": 6713,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/filter/SearchResultFilter.java",
"chars": 917,
"preview": "\n/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framewor"
},
{
"path": "src/main/java/com/graphaware/es/gas/modifier/PrivilegedSearchResultModifier.java",
"chars": 1646,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/modifier/SearchResultModifier.java",
"chars": 1034,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/util/Instantiator.java",
"chars": 5273,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/util/NumberUtil.java",
"chars": 1494,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/util/ParamUtil.java",
"chars": 1340,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/util/PluginClassLoader.java",
"chars": 2126,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/util/UrlUtil.java",
"chars": 1652,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/wrap/ActionListenerWrapper.java",
"chars": 1135,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/wrap/CannotWrapException.java",
"chars": 918,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/wrap/GraphAidedSearchActionListenerWrapper.java",
"chars": 10950,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/java/com/graphaware/es/gas/wrap/WrappingActionListener.java",
"chars": 9411,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/main/plugin-metadata/plugin-descriptor.properties",
"chars": 1028,
"preview": "#\n# Copyright (c) 2013-2016 GraphAware\n#\n# This file is part of the GraphAware Framework.\n#\n# GraphAware Framework is fr"
},
{
"path": "src/main/plugin-metadata/plugin-security.policy",
"chars": 575,
"preview": "grant {\n //permission org.elasticsearch.script.ClassPermission \"java.lang.*\"; // allow class`\n //permission java.lang."
},
{
"path": "src/test/java/com/graphaware/es/gas/EmbeddedGraphDatabaseServerTest.java",
"chars": 1035,
"preview": "/*\n * To change this license header, choose License Headers in Project Properties.\n * To change this template file, choo"
},
{
"path": "src/test/java/com/graphaware/es/gas/GraphAidedSearchFilterTest.java",
"chars": 724,
"preview": "package com.graphaware.es.gas;\n\nimport org.elasticsearch.common.settings.Settings;\nimport org.junit.Test;\n\nimport static"
},
{
"path": "src/test/java/com/graphaware/es/gas/GraphAidedSearchIntegrationBoltTest.java",
"chars": 5709,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/test/java/com/graphaware/es/gas/GraphAidedSearchIntegrationTest.java",
"chars": 21144,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/test/java/com/graphaware/es/gas/GraphAidedSearchNeo4jIntegrationTest.java",
"chars": 20129,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/test/java/com/graphaware/es/gas/GraphAidedSearchTest.java",
"chars": 7115,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/test/java/com/graphaware/es/gas/JestMsgResult.java",
"chars": 1108,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/test/java/com/graphaware/es/gas/MockServerTest.java",
"chars": 3858,
"preview": "package com.graphaware.es.gas;\n\nimport com.graphaware.es.gas.domain.ExternalResult;\nimport com.sun.jersey.api.client.Cli"
},
{
"path": "src/test/java/com/graphaware/es/gas/booster/GraphBoosterTest.java",
"chars": 3489,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/test/java/com/graphaware/es/gas/booster/SearchResultCypherBoltBoosterTest.java",
"chars": 2318,
"preview": "/*\n * To change this license header, choose License Headers in Project Properties.\n * To change this template file, choo"
},
{
"path": "src/test/java/com/graphaware/es/gas/booster/SearchResultCypherBoosterTest.java",
"chars": 6735,
"preview": "package com.graphaware.es.gas.booster;\n\nimport com.graphaware.es.gas.GraphAidedSearchTest;\nimport com.graphaware.es.gas."
},
{
"path": "src/test/java/com/graphaware/es/gas/booster/SearchResultNeo4jBoosterTest.java",
"chars": 9237,
"preview": "package com.graphaware.es.gas.booster;\n\nimport com.graphaware.es.gas.domain.IndexInfo;\nimport com.graphaware.es.gas.anno"
},
{
"path": "src/test/java/com/graphaware/es/gas/domain/CypherEndpointBoltTest.java",
"chars": 2549,
"preview": "package com.graphaware.es.gas.domain;\n\nimport com.graphaware.es.gas.cypher.CypherEndPoint;\nimport com.graphaware.es.gas."
},
{
"path": "src/test/java/com/graphaware/es/gas/domain/CypherEndpointTest.java",
"chars": 3651,
"preview": "package com.graphaware.es.gas.domain;\n\nimport com.graphaware.es.gas.cypher.CypherEndPoint;\nimport com.graphaware.es.gas."
},
{
"path": "src/test/java/com/graphaware/es/gas/domain/CypherEndpointUnitTest.java",
"chars": 1893,
"preview": "package com.graphaware.es.gas.domain;\n\nimport com.graphaware.es.gas.cypher.CypherEndPoint;\nimport com.graphaware.es.gas."
},
{
"path": "src/test/java/com/graphaware/es/gas/domain/ExternalResultTest.java",
"chars": 355,
"preview": "package com.graphaware.es.gas.domain;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\npublic class ExternalR"
},
{
"path": "src/test/java/com/graphaware/es/gas/domain/ExternalResultUnitTest.java",
"chars": 865,
"preview": "package com.graphaware.es.gas.domain;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\npublic class ExternalR"
},
{
"path": "src/test/java/com/graphaware/es/gas/domain/TestIndexInfo.java",
"chars": 918,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/test/java/com/graphaware/es/gas/filter/GraphFilterTest.java",
"chars": 1757,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/test/java/com/graphaware/es/gas/filter/SearchResultCypherFilterTest.java",
"chars": 2503,
"preview": "package com.graphaware.es.gas.filter;\n\nimport com.graphaware.es.gas.domain.IndexInfo;\nimport com.graphaware.es.gas.domai"
},
{
"path": "src/test/java/com/graphaware/es/gas/stubs/CypherSearchResultTestBooster.java",
"chars": 1724,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/test/java/com/graphaware/es/gas/stubs/CypherSearchResultTestFilter.java",
"chars": 1591,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/test/java/com/graphaware/es/gas/stubs/SearchResultTestBooster.java",
"chars": 1696,
"preview": "/*\n * Copyright (c) 2013-2016 GraphAware\n *\n * This file is part of the GraphAware Framework.\n *\n * GraphAware Framework"
},
{
"path": "src/test/java/com/graphaware/es/gas/util/ClauseConstantsTest.java",
"chars": 2117,
"preview": "/*\n * To change this license header, choose License Headers in Project Properties.\n * To change this template file, choo"
},
{
"path": "src/test/java/com/graphaware/es/gas/util/NumberUtilTest.java",
"chars": 1130,
"preview": "package com.graphaware.es.gas.util;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\npublic class NumberUtilT"
},
{
"path": "src/test/java/com/graphaware/es/gas/util/TestHttpClient.java",
"chars": 10709,
"preview": "package com.graphaware.es.gas.util;\n\nimport org.apache.http.HttpResponse;\nimport org.apache.http.HttpStatus;\nimport org."
},
{
"path": "src/test/java/com/graphaware/es/gas/util/UrlUtilTest.java",
"chars": 486,
"preview": "package com.graphaware.es.gas.util;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.assertEquals;\n\npublic class "
},
{
"path": "src/test/resources/demo-data-reduced.cyp",
"chars": 19149,
"preview": "CREATE CONSTRAINT ON (person:Person) ASSERT person.neogen_id IS UNIQUE;\nCREATE CONSTRAINT ON (skill:Skill) ASSERT skill."
},
{
"path": "src/test/resources/demo-data.cyp",
"chars": 1821789,
"preview": "CREATE CONSTRAINT ON (person:Person) ASSERT person.neogen_id IS UNIQUE;\nCREATE CONSTRAINT ON (skill:Skill) ASSERT skill."
},
{
"path": "src/test/resources/graphgen-test-data.cyp",
"chars": 50236,
"preview": "CREATE CONSTRAINT ON (person:Person) ASSERT person.neogen_id IS UNIQUE;\nMERGE (n1:Person {neogen_id: 'fa4e5e41522d25bd27"
},
{
"path": "src/test/resources/neo4j-elasticsearch-reco.properties",
"chars": 1357,
"preview": "#\n# Copyright (c) 2013-2016 GraphAware\n#\n# This file is part of the GraphAware Framework.\n#\n# GraphAware Framework is fr"
},
{
"path": "src/test/resources/neo4j-elasticsearch.properties",
"chars": 1266,
"preview": "#\n# Copyright (c) 2013-2016 GraphAware\n#\n# This file is part of the GraphAware Framework.\n#\n# GraphAware Framework is fr"
},
{
"path": "src/test/resources/neo4j-server-es.properties",
"chars": 849,
"preview": "#\n# Copyright (c) 2013-2016 GraphAware\n#\n# This file is part of the GraphAware Framework.\n#\n# GraphAware Framework is fr"
}
]
About this extraction
This page contains the full source code of the graphaware/graph-aided-search GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 74 files (2.1 MB), approximately 551.0k tokens, and a symbol index with 423 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.