Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
STMW A2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christine Brovkina
STMW A2
Merge requests
!11
defining document fields. check the TODO
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
defining document fields. check the TODO
master
into
main
Overview
0
Commits
1
Changes
4
Merged
Christine Brovkina
requested to merge
master
into
main
3 years ago
Overview
0
Commits
1
Changes
4
Expand
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
f42fd652
1 commit,
3 years ago
4 files
+
33
−
18
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
Indexer.java
+
11
−
7
Options
@@ -38,10 +38,15 @@ public class Indexer {
}
public
static
void
insertDoc
(
IndexWriter
i
,
String
item_id
,
String
name
,
String
category
,
String
description
){
Document
doc
=
new
Document
();
doc
.
add
(
new
TextField
(
"item_id"
,
line
,
Field
.
Store
.
YES
));
doc
.
add
(
new
TextField
(
"name"
,
line
,
Field
.
Store
.
YES
));
doc
.
add
(
new
TextField
(
"category"
,
line
,
Field
.
Store
.
YES
));
doc
.
add
(
new
TextField
(
"description"
,
line
,
Field
.
Store
.
YES
));
doc
.
add
(
new
TextField
(
"item_id"
,
item_id
,
Field
.
Store
.
YES
,
Field
.
Index
.
NOT_ANALYZED
));
//TODO: latitude and longitude?
doc
.
add
(
new
TextField
(
"name"
,
item_name
,
Field
.
Store
.
YES
,
Field
.
Index
.
ANALYZED
,
Field
.
TermVector
.
WITH_POSITIONS_OFFSETS
));
for
(
String
category
:
categories
)
{
doc
.
add
(
new
TextField
(
"category"
,
item_category
,
Field
.
Store
.
YES
,
Field
.
Index
.
ANALYZED
));
}
doc
.
add
(
new
TextField
(
"description"
,
item_description
,
Field
.
Store
.
YES
,
Field
.
Index
.
ANALYZED
,
Field
.
TermVector
.
WITH_POSITIONS_OFFSETS
));
try
{
i
.
addDocument
(
doc
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@@ -51,9 +56,9 @@ public class Indexer {
long
start
=
System
.
currentTimeMillis
();
//keep track of the time
Path
path
=
Paths
.
get
(
indexPath
);
System
.
out
.
println
(
"Indexing to directory '"
+
indexPath
+
"'...\n"
);
Directory
directory
=
FSDirectory
.
open
(
path
);
//ANALYZER
// DEFINE ANALYZER
IndexWriterConfig
config
=
new
IndexWriterConfig
(
new
SimpleAnalyzer
());
//IndexWriterConfig config = new IndexWriterConfig(new StandardAnalyzer());
//IndexWriterConfig config = new IndexWriterConfig(new EnglishAnalyzer());
@@ -61,7 +66,6 @@ public class Indexer {
//--START INDEXING--
IndexWriter
i
=
new
IndexWriter
(
directory
,
config
);
i
.
deleteAll
();
//keep count
//--OPEN DB CONNECTION--
conn
=
DbManager
.
getConnection
(
true
);
Loading