Skip to content

Commit ad4a7dd

Browse files
committed
relocated from getting-started-search-java so it can be versioned on its own
1 parent 4da51ed commit ad4a7dd

16 files changed

Lines changed: 763 additions & 1 deletion

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# Linux start script should use lf
5+
/gradlew text eol=lf
6+
7+
# These are Windows script files and should use crlf
8+
*.bat text eol=crlf
9+

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ignore Gradle project-specific cache directory
2+
.gradle
3+
4+
# Ignore Gradle build output directory
5+
build

README.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,52 @@
1-
# atlas-search-java-server
1+
# Atlas Search Server
2+
3+
This Search Server code was initially written to support the article
4+
("How to Build a Search Service in Java with MongoDB")[TBD] and video[TBD].
5+
6+
It uses the `jettyRun` target and searches the `movies_index`. The search
7+
server code lives under `server/`
8+
9+
To run the search server locally, follow these steps:
10+
11+
* Add the [sample collections](https://www.mongodb.com/docs/atlas/sample-data/) to your Atlas cluster
12+
* If you're not already an Atlas user, [get started with Atlas](https://www.mongodb.com/docs/atlas/getting-started/)
13+
* [Create an Atlas Search index](https://www.mongodb.com/docs/atlas/atlas-search/tutorial/create-index/) on the `movies` collection, named `movies_index`, using the index
14+
configuration below.
15+
* `cd server/` - work within the server directory.
16+
* Run the search service:
17+
`ATLAS_URI="<<insert your connection string here>>" ./gradlew jettyRun`
18+
* Visit [http://localhost:8080](http://localhost:8080)
19+
20+
`movies_index` index configuration (JSON):
21+
```
22+
{
23+
"analyzer": "lucene.english",
24+
"searchAnalyzer": "lucene.english",
25+
"mappings": {
26+
"dynamic": true,
27+
"fields": {
28+
"cast": [
29+
{
30+
"type": "token"
31+
},
32+
{
33+
"type": "string"
34+
}
35+
],
36+
"genres": [
37+
{
38+
"type": "token"
39+
},
40+
{
41+
"type": "string"
42+
}
43+
]
44+
}
45+
}
46+
}
47+
```
48+
49+
_id: {
50+
$toString: "$_id"
51+
}
52+

build.gradle

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
plugins {
2+
id 'java'
3+
id 'war'
4+
id 'org.gretty' version '4.1.1'
5+
}
6+
7+
group 'com.mongodb.atlas.search'
8+
version '1.0-SNAPSHOT'
9+
10+
repositories {
11+
mavenCentral()
12+
}
13+
14+
dependencies {
15+
implementation 'org.mongodb:mongodb-driver-sync:4.10.1'
16+
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.17.1'
17+
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
18+
}
19+
20+
gretty {
21+
contextPath = '/'
22+
}
23+
24+
product {
25+
webapp project
26+
}

gradle.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This file was generated by the Gradle 'init' task.
2+
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties
3+
4+
org.gradle.parallel=true
5+
org.gradle.caching=true
6+

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This file was generated by the Gradle 'init' task.
2+
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format

gradle/wrapper/gradle-wrapper.jar

42.4 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

gradlew

Lines changed: 249 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)