38 Commits

Author SHA1 Message Date
David Ostrovsky
41eae482e8 Fix eclipse project generation
In Ibe62917e20 maven jar merging using python was replaced with
java_binary rule. Fix eclipse project generation and also clean up
left over unused import statement and script.

Change-Id: I46b14f8e8e380f38962937be253fb1b7e4fa147d
2020-01-10 21:38:35 +01:00
Han-Wen Nienhuys
1fdd3f7b27 lib/lucene: merge jars using a java_binary rule
In I42fd1a130e ("Merge Lucene core and backward-codecs jars"), Dave
Borowitz introduced a script to concatenate META-INF/services/ files
for Codecs.

Buck would randomly pick one of the two service files. The solution
was to explicitly pick the first entry for class files, and
concatenate service files.

In Bazel, we can have Bazel do the work of merging jars. This is done
with the java_binary rule. This concatenates the service files, and
picks a single .class file from each input jar, as determined by the
ordering in the jars attribute.

Delete tools/merge_jars.py, as this was its only use. This also fixes
an issue where Mac users need to specify --host_force_python=PY2 if
they don't have Python 3.

Change-Id: Ibe62917e20eeb1824967782d4d510f3f63775fce
2020-01-08 23:06:40 +01:00
David Ostrovsky
20c2fd4f0b Bazel: Add fixes for --incompatible_load_{java|python}_rules_from_bzl
This change is fixing "All Java build rules should be loaded from
Starlark" warning flagged by latest buildifier version: [1]. Python
rules are now also loaded from the Starlark.

Also extract codemirror library import to BUILD file. This is needed to
avoid cycle in the workspace file, after importing java rules from
Starlark.

[1] https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#native-java

Change-Id: I36192c9465d988b25cf09c250e110f15850910cd
2019-09-02 00:42:25 +02:00
David Ostrovsky
930f29e2fd Bazel: Automatically fix lint errors with buildifier
In recent buildifier versions, lint errors can be fixed automatically:

  $ find . \( -name BUILD -o -name "*.bzl" \) -print \
      | xargs buildifier --lint=fix

This commit was created with Buildifier version 0.19.2:

  $ buildifier --version
buildifier version: 0.19.2
buildifier scm revision: d39e4d5c25111527369142f16cdb49aa67707313

Change-Id: I1f06cd4596e794981ccc2d9fc2d1da9b17f3973a
2019-01-08 23:11:59 +01:00
David Pursehouse
1fa4bcfb6e Bazel: Clean up package visibility settings
For packages having a default visiblity defined, it is redundant to also
set the same visibility per package, so remove those.

For packages that only have one rule, and its visibility differs from the
default visibility, remove the default visibility.

Also clean up wrapping of some of the default definitions.

Change-Id: I9e81c3f724b4ffde7a652b485d33c650866ad122
2018-12-07 11:07:41 +09:00
David Ostrovsky
f98a60b35f Bazel: Harmonize names of external repositories
Recent Bazel versions support dash character in external repository
names. Consistently use them with one exception: javax_inject. This is
needed to match the name in the rules_closure.

Change-Id: I1e75690fe1ee2ab32fffe07c0c30dbed84753960
2018-06-08 19:33:01 +09:00
David Ostrovsky
5f40a6adff Acceptance tests: Replace embedded ES with docker testcontainer
Testcontainers is a Java 8 library that supports JUnit tests, providing
lightweight, throwaway instances of common databases, Selenium web
browsers, or anything else that can run in a Docker container.

This change replaces ES integration test that currently uses embedded
ES mode with ES docker image using Testcontainers library. All this is
done from within acceptance tests.

This change removes dependency on ES server stack for the test code. As
the consequence, this stack can be removed.

Prerequisite for this change is installed docker service on the SUT. If
docker service is not installed, assumption violation is raised so that
the tests don't fail. Unfortunately, due to this missing Bazel feature,
JUnit assumption violations are not reflected on the Bazel UI: [1] yet.

[1] https://github.com/bazelbuild/bazel/issues/3476

Change-Id: Iccf44310292cc44bff9173f2a4ea757b43f77183
2018-05-28 14:30:23 +09:00
Marco Miller
40744d99ff lib/elasticsearch: remove unnecessary dependencies
Remove the hereby no longer used ones also from libs thus WORKSPACE.

Bug: Issue 6094
Change-Id: Icb0ee8dd89ae30c1256ae60481eb782798f252ef
2018-04-13 16:04:42 -04:00
David Ostrovsky
fdbfcad77d Remove Buck based build
Bug: Issue 5302
Change-Id: I6e860446ef30ff0ad1c7c49fc0e39d39d921820b
2017-01-23 12:44:58 +00:00
David Ostrovsky
fa18907d7f Bazel: Reformat build files
Reformat the Bazel build files with the buildifier tool [1].

The style is different for Bazel files. Most notably, indentation level
is 4 spaces instead of 2, and " is used instead of '.

[1] https://github.com/bazelbuild/buildifier

Change-Id: I95c0c6f11b6d76572797853b4ebb5cee5ebd3c98
2016-12-07 11:33:07 +00:00
Han-Wen Nienhuys
5e4491886b bazel: update for elasticsearch and lucene.
Change-Id: Icb9f9f0344b10a008d5b353362933890446eb544
2016-09-28 21:17:08 +02:00
David Pursehouse
8e72f5301b Add support for secondary index with Elasticsearch
Add support for secondary index on Elasticsearch via the REST API
using the Jest client [1].

Because Elasticsearch uses different version of Lucene we add another
maven_jar's in gerrit-elasticsearch BUCK. Fortunately both versions have
compatible API, this way we are able to compile and run Gerrit.

All tests for changes index passes, but they need to use Lucene's based
account index.

[1] http://www.searchly.com/documentation/developer-api-guide/java-jest/

TODO: Add support for online reindex
TODO: Add support for schema upgrades

Also-By: Janice Agustin <janice.agustin@ericsson.com>
Also-By: Olga Grinberg <olga.grinberg@ericsson.com>
Also-By: Dariusz Luksza <dluksza@collab.net>
Change-Id: I5e4fc08ce34d33c090c9e0bf320de1b17309f774
2016-09-27 23:27:37 +09:00
David Pursehouse
b4d30002d6 Downgrade Lucence back to 5.5.2
We need to have the same version in core Gerrit as is used by
Elasticsearch.

This reverts commit f18c2256d56ed9574429e0934de2acda47a4a065.

Change-Id: Ib8e403680be961406b67bf30069c9061f0445195
2016-09-27 23:27:24 +09:00
Yuxuan 'fishy' Wang
75b98f77d9 bazel: add license to appropriate lib/ targets
This is to prepare for implementing genlicenses rule in bazel.

Change-Id: I60d79d5b53f9dd05c9f9ebfe6e6f658604c5a037
2016-09-26 16:42:38 +08:00
Patrick Hiesel
f18c2256d5 Update Lucene from 5.5.2 to 5.5.3
Minor update to establish library compliance. Lucene changelog [0] says
it only contains one bugfix.

[0] http://www.us.apache.org/dist/lucene/java/5.5.3/changes/Changes.html

Change-Id: I133e2e2845984fb7d27ba499247bb639e8457297
2016-09-16 10:48:53 -04:00
David Pursehouse
f5649ef68d Upgrade Lucene to 5.5.2
Version 5.5.2 is the latest release of 5.x before 6.x and will
be used in Elasticsearch 2.4.0 [1].

[1] https://github.com/elastic/elasticsearch/pull/19496

Change-Id: Ice4ca86fe141bc42abcdc25867761dc6f4272851
2016-08-30 06:48:56 +00:00
David Pursehouse
674d92c998 Upgrade Lucene to 5.5.0
This is not the latest version on the 5.x series, but is the version
used in the latest release of Elasticsearch.

Change-Id: Iddc6852cc1e2e338e4d026b0ba3438e8f26fc812
2016-07-20 09:59:13 +09:00
David Ostrovsky
b81b4f75ae Implement Bazel build
To run the tests:

  bazel test //...

To build the Gerrit plugin API, run:

  bazel build gerrit-plugin-api:plugin-api_deploy.jar

To build the Gerrit extension API, run:

  bazel build gerrit-extension-api:extension-api_deploy.jar

TODOs:

Licenses
Reduce visibility (all public for now)
Generate HTML Documentation
Core plugins
gerrit_plugin() rule to build plugins in tree and standalone modes
GWT UI (only gwt_module() skylark rule is provided, no gwt_binary())
PolyGerrit UI
WAR
Publish artifacts to Maven Central
Ask Bazel team to add Gerrit to their CI on ci.bazel.io

Contributed-By: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I9a86e670882a44a5c966579cdeb8ed79b1590de3
2016-06-14 21:12:02 +02:00
Bruce Zu
77e5dc88cf Fix typo in lib/lucene/BUCK
Replace ':core_jar' with ':lucene-core'. Buck cannot resolve ':core_jar'.

Change-Id: Ie14327752bed4bb8b9e3da03994e9100436956e5
2016-02-19 08:17:21 +01:00
David Pursehouse
5a3bdadb03 Lucene: Add back the core-and-backward-codecs target
This is needed after the upgrade to Lucene 5.4.1.

This partially reverts commit fc70ea396173a667b13272646997e222bb4d0756.

Change-Id: Ie8f4449a08ff951278863bddf39016a951a05067
2016-02-08 14:50:18 +09:00
Dave Borowitz
3b553fa968 Upgrade Lucene to 5.4.1
Change-Id: I9acd9302225a20980d5d5a1cd1ce95cc1c22fe61
2016-02-05 09:28:42 -05:00
Dave Borowitz
fc70ea3961 Remove support for pre-Lucene 5 indexes
These hacks were added in 70aaf7ea to continue supporting old index
versions stored on disk, which was necessary to upgrade v14 to v25
for 2.11->2.12. Now that stable-2.12 has been cut, we can remove
support for this.

Get rid of the core-and-backward-codecs target and just use core. A
side effect of this change is that pack_war.py would now fail, since
it expects each jar that goes in lib/ to have a unique name, and there
is already a "core" target in MINA. Prefix all the lucene targets with
"lucene-" to get it working.

Change-Id: I146fc74ed649e0a44503f42bfa5822bf6fba5c03
2015-12-22 11:36:29 -05:00
David Pursehouse
3969b14ec9 Update Lucene to version 5.3.1
This is a minor release that fixes a few bugs.

See the release notes for details.

https://lucene.apache.org/core/5_3_1/changes/Changes.html

Change-Id: Ia5b6df0f446fb7122ffe36156814b80c4ac3a9be
2015-11-06 12:14:50 +09:00
David Pursehouse
3ace71cbec Upgrade Lucene to version 5.3.0
This version includes a number of new features and bugfixes.

It also includes an API change that causes deprecation
warnings:

- BooleanQuery is now immutable and can be built using the
  BooleanQuery.Builder class

Instantiate instances of BooleanQuery with the new builder class
instead of with its constructor.

See the release notes for full details:

https://lucene.apache.org/core/5_3_0/changes/Changes.html

Change-Id: I5954b10017f2ff1531b036f953c6e4488e338f0e
2015-09-04 07:54:08 +00:00
Dave Borowitz
9a4efd3fff Merge Lucene core and backward-codecs jars
Both of these jars provide a provider-configuration file in
META-INF/services/org.apache.lucene.codecs.Codec registering their
respective implementations as providers of this codec. The proper way
to merge these files is to concatenate them, but the normal Buck build
process would otherwise choose one arbitrarily.

Add a new custom rule merge_maven_jars to merge multiple Maven jars
together using a simple Python script. The script concatenates all the
entries in two zip files, preferring the entry found in the first file
on the command line, which is still arbitrary but at least
deterministic. It specially handles files in the META-INF/services
directory by concatenating them.

Use this new rule to merge the old :core and :backward-codecs rules
into a single :core-and-backward-codecs rule.

Change-Id: I42fd1a130e42cb0eebf7bee61cfdf8545397cd09
2015-09-01 14:34:25 -04:00
David Pursehouse
875f46955a Upgrade Lucene to version 5.2.1
Versions 5.2.0 [1] and 5.2.1 [2] contain several bugfixes and
optimizations since version 5.1.0.

[1] https://lucene.apache.org/core/5_2_0/changes/Changes.html#v5.2.0.bug_fixes
[2] https://lucene.apache.org/core/5_2_1/changes/Changes.html#v5.2.1.bug_fixes

Change-Id: I1a530ed92c5a3e7845c7aa61f54a26b0ace65e88
2015-06-24 14:59:49 +09:00
David Pursehouse
84dd8e468b Lucene: Rename query-parser to queryparser to match Maven artifact name
Change-Id: I9a66dcef214283bf6c4945301720d68d7bcc6251
2015-06-24 14:59:49 +09:00
David Pursehouse
7bb169dce1 Upgrade Lucene to 5.1.0
There is nothing specific that we need in this version.  It might be
needed for the Elasticsearch integration, and somewhat reduces the
changes that will potentially be needed when upgrading to 5.2.0 or
later.

Change-Id: Iafb3b13c302fa37ec1b4ce72d01c489b05169e07
2015-04-28 09:13:19 +00:00
Dave Borowitz
70aaf7eaa7 Update Lucene to 5.0.0
Use this version starting at the existing schema version 15 (which has
been in master for only a week or so).

Notable changes:

 - Can use the new IndexWriter#setCommitOnClose(boolean) method to
   simplify closing an index.

 - This means we no longer need to pass Version into the
   IndexWriterConstructor. According to [1], this was _only_ used to
   determine whether or not the index should be committed on close, as
   this behavior differed between versions. No more mapping schema
   versions to Lucene versions!

 - IndexWriters are now forced to use their configured Analyzer,
   removing the methods taking an Analyzer (which we weren't using
   anyway). This saves some code in AutoCommitWriter.

 - Lucene 5 cannot read indexes created by older versions without an
   additional jar in the classpath, so we need to add that.

The most annoying change is that sorting cannot be done on normal
numeric fields by default anymore[2]. This was inefficient anyway, as
Lucene had to seek and read all index field values before doing the
sorting. Switch to the newer DocValues API for strongly-typed sortable
fields. This introduces some medium-term ugliness as the sort spec
changes depending on the schema version.

Unfortunately we can only use DocValues on new index versions; older
versions need to use the new UninvertingReader API, which provides
FieldCache based sorting without a reindex. An overzealous check in a
static method in Lucene[3] means we need to temporarily fork
SearcherManager.java from Lucene in order to get this to work with the
NRT machinery.

Since we have to jump through significant hoops to get older index
versions readable by this version of Lucene, add a test specifically
for schema v14.

[1] https://issues.apache.org/jira/browse/LUCENE-5871
[2] https://issues.apache.org/jira/browse/LUCENE-5666
[3] https://issues.apache.org/jira/browse/LUCENE-6370

Change-Id: I843be2fb697779fc741e25459a2716280b2bd0b6
2015-03-25 12:21:59 -07:00
David Pursehouse
9ac0746423 Update Lucene to version 4.10.2
Version 4.10.2 includes a couple of bug fixes [1], but these are not
necessarily needed by Gerrit.

This update is needed because Elasticsearch 1.4.0 has a dependency
on this version [2].

There is no change in the index format since 4.10.1 so we reuse the
same version number for the Lucene backed change index.

[1] http://lucene.apache.org/core/4_10_2/changes/Changes.html#v4.10.2.bug_fixes
[2] http://mvnrepository.com/artifact/org.elasticsearch/elasticsearch/1.4.0

Change-Id: Ie47dd2238493da44659c73c7f97f0caa2f7fdfa4
2014-11-18 09:15:07 +09:00
Dave Borowitz
2ab1af186e Store mergeable field from cache in index
Eventually this will no longer be part of the serialized change proto,
and even with the cache it is still expensive to check mergeability
for each change in a list of search results, as the submit type must
still be checked in order to look up the mergeability.

The new MERGEABLE field now loads from the cache, although ChangeJson
and several other callers still depend on the field in Change. This
will facilitate index schema upgrades, in that a full reindex will
also populate the persistent cache.

While we're at it, upgrade Lucene to 4.10.1, which contains some
important stability bugfixes[1].

[1] http://lucene.apache.org/core/4_10_1/changes/Changes.html#v4.10.1

Change-Id: I166b85f91bd596a3f0295616c2e72853b692dd54
2014-11-03 12:08:34 -08:00
David Ostrovsky
4995c3d90e Bump Lucene version to 4.10
Change-Id: Id13cde38fd640130f31e9a78d8d4da5d7c280649
2014-09-05 12:13:33 -07:00
Jeff Davidson
45d0a772e1 Add search fields for # of changed lines.
Based off https://gerrit-review.googlesource.com/#/c/52190, but
implementing the final suggestion of indexing raw delta counts and
allowing arbitrary range queries off of those.

Also upgrade Lucene to 4.8.1 as this was released since the last
schema change (which was on 4.7.0).

Change-Id: Ia8a677e71e133f68eced4c5394df1d23efe7f12a
2014-05-23 10:16:15 -07:00
Dave Borowitz
4aed07b7ce Add a "projects" field for searching projects by prefix
Index alongside the "project" field, which is an exact match field,
since we do not assume index implementations can search exact match
and prefix on the same field. We do not want to modify the existing
"project" to return prefixes.

Upgrade Lucene to 4.7.0, as this was released since the last schema
change.

Change-Id: I7c3379c087fc54af3e5790cb875a5e676e674338
2014-03-25 16:38:59 -07:00
David Ostrovsky
20d672e49f Bump Lucene version to 4.6.0
Also remove unused artifacts from the Buck file.

Gerrit gitblit plugin must ship Lucene binaries in shaded jar, because
the versions of Lucene that Gerrit and Gitblit ship are different.

This change and this pull request [1] harmonize the Lucene versions in Gerrit
and Gitblit distributions.

[1] https://github.com/gitblit/gitblit/pull/124

Change-Id: Ib94a288b60445d73f617174d58f69e4fe91b4d36
2013-12-27 10:08:18 -08:00
Yuxuan 'fishy' Wang
ec4b06a6e2 REST endpoint for searching Gerrit documentation.
The documentation of this endpoint is available in
rest-api-docsearch[.txt|.html].

The UI of showing the search result and doing the search will be in a
separate change.

Change-Id: Ifa4f5a7d576ada7f88a4fa1b765a38cba6d7e964
2013-10-18 18:33:17 -07:00
Dave Borowitz
3d271c0c66 Update Lucene to 4.4.0
Of note in this version upgrade is the replacement of NrtManager by
ControlledRealTimeReopenThread, which has a different API as used by
SubIndex.

Change-Id: Id34eb8e75bb07a38be9b5ed9a1cdeaf195774b58
2013-10-02 12:00:41 -07:00
Ahaan Ugale
404c8246bc Add secondary index implementation using SolrCloud
SolrCloud can be used instead of Lucene by adding "type = SOLR"
under [index] and "url = <zookeeper-url>" under [index "solr"]
in gerrit.config.

Change-Id: I0ff8579c5e23c58b16f3605bc20eba4e80fb40fc
2013-06-27 13:52:39 -07:00