mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-10-14 22:38:56 +00:00
DATAES-2 - all code reformatted to follow Spring Data code rules
This commit is contained in:
parent
f768c1698e
commit
e9a260235d
@ -133,7 +133,7 @@ Searching entities using Elasticsearch Template
|
|||||||
Indexing a single document with Repository
|
Indexing a single document with Repository
|
||||||
|
|
||||||
```java
|
```java
|
||||||
@Resource
|
@Autowired
|
||||||
private SampleElasticsearchRepository repository;
|
private SampleElasticsearchRepository repository;
|
||||||
|
|
||||||
String documentId = "123456";
|
String documentId = "123456";
|
||||||
@ -147,7 +147,7 @@ Indexing a single document with Repository
|
|||||||
Indexing multiple Document(bulk index) using Repository
|
Indexing multiple Document(bulk index) using Repository
|
||||||
|
|
||||||
```java
|
```java
|
||||||
@Resource
|
@Autowired
|
||||||
private SampleElasticsearchRepository repository;
|
private SampleElasticsearchRepository repository;
|
||||||
|
|
||||||
String documentId = "123456";
|
String documentId = "123456";
|
||||||
@ -371,6 +371,11 @@ Here are some ways for you to get involved in the community:
|
|||||||
|
|
||||||
Before we accept a non-trivial patch or pull request we will need you to sign the [contributor's agreement](https://support.springsource.com/spring_committer_signup). Signing the contributor's agreement does not grant anyone commit rights to the main repository, but it does mean that we can accept your contributions, and you will get an author credit if we do. Active contributors might be asked to join the core team, and given the ability to merge pull requests.
|
Before we accept a non-trivial patch or pull request we will need you to sign the [contributor's agreement](https://support.springsource.com/spring_committer_signup). Signing the contributor's agreement does not grant anyone commit rights to the main repository, but it does mean that we can accept your contributions, and you will get an author credit if we do. Active contributors might be asked to join the core team, and given the ability to merge pull requests.
|
||||||
|
|
||||||
|
|
||||||
|
Code formatting for [Eclipse and Intellij](https://github.com/spring-projects/spring-data-build/tree/master/etc/ide)
|
||||||
|
|
||||||
|
[More information about contributing to Spring Data](https://github.com/spring-projects/spring-data-build/blob/master/CONTRIBUTING.md)
|
||||||
|
|
||||||
### Contact Details
|
### Contact Details
|
||||||
|
|
||||||
* Rizwan Idrees (rizwan.idrees@biomedcentral.com)
|
* Rizwan Idrees (rizwan.idrees@biomedcentral.com)
|
||||||
|
820
formatting.xml
820
formatting.xml
@ -1,820 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<profiles version="12">
|
|
||||||
<profile kind="CodeFormatterProfile" name="Spring Data"
|
|
||||||
version="12">
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags"
|
|
||||||
value="insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.disabling_tag"
|
|
||||||
value="@formatter:off" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration"
|
|
||||||
value="end_of_line" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries"
|
|
||||||
value="true" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field"
|
|
||||||
value="0" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags"
|
|
||||||
value="false" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line"
|
|
||||||
value="false" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases"
|
|
||||||
value="true" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields"
|
|
||||||
value="16" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer"
|
|
||||||
value="16" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression"
|
|
||||||
value="80" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer"
|
|
||||||
value="end_of_line" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while"
|
|
||||||
value="insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package"
|
|
||||||
value="1" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters"
|
|
||||||
value="insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation"
|
|
||||||
value="2" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation"
|
|
||||||
value="16" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk"
|
|
||||||
value="1" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator"
|
|
||||||
value="insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package"
|
|
||||||
value="0" />
|
|
||||||
<setting id="org.eclipse.jdt.core.compiler.source" value="1.7" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments"
|
|
||||||
value="true" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations"
|
|
||||||
value="insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines"
|
|
||||||
value="true" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call"
|
|
||||||
value="16" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type"
|
|
||||||
value="1" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.align_type_members_on_columns"
|
|
||||||
value="false" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation"
|
|
||||||
value="16" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description"
|
|
||||||
value="true" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment"
|
|
||||||
value="false" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration"
|
|
||||||
value="insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration"
|
|
||||||
value="0" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method"
|
|
||||||
value="insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.indentation.size"
|
|
||||||
value="2" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.enabling_tag"
|
|
||||||
value="@formatter:on" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration"
|
|
||||||
value="16" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment"
|
|
||||||
value="0" />
|
|
||||||
<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier"
|
|
||||||
value="error" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.char"
|
|
||||||
value="tab" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body"
|
|
||||||
value="true" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method"
|
|
||||||
value="1" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested"
|
|
||||||
value="true" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line"
|
|
||||||
value="false" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration"
|
|
||||||
value="16" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration"
|
|
||||||
value="end_of_line" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration"
|
|
||||||
value="0" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch"
|
|
||||||
value="end_of_line" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments"
|
|
||||||
value="false" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier"
|
|
||||||
value="error" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch"
|
|
||||||
value="false" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block"
|
|
||||||
value="end_of_line" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration"
|
|
||||||
value="end_of_line" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.compact_else_if"
|
|
||||||
value="true" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch"
|
|
||||||
value="true" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column"
|
|
||||||
value="true" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant"
|
|
||||||
value="end_of_line" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags"
|
|
||||||
value="true" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch"
|
|
||||||
value="16" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.size"
|
|
||||||
value="2" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment"
|
|
||||||
value="false" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration"
|
|
||||||
value="16" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator"
|
|
||||||
value="insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines"
|
|
||||||
value="false" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case"
|
|
||||||
value="end_of_line" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve"
|
|
||||||
value="1" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression"
|
|
||||||
value="16" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter"
|
|
||||||
value="insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.7" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer"
|
|
||||||
value="2" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression"
|
|
||||||
value="16" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line"
|
|
||||||
value="false" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration"
|
|
||||||
value="insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line"
|
|
||||||
value="false" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration"
|
|
||||||
value="16" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression"
|
|
||||||
value="16" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration"
|
|
||||||
value="end_of_line" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode"
|
|
||||||
value="enabled" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line"
|
|
||||||
value="true" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant"
|
|
||||||
value="16" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments"
|
|
||||||
value="true" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.line_length"
|
|
||||||
value="120" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups"
|
|
||||||
value="1" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration"
|
|
||||||
value="end_of_line" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body"
|
|
||||||
value="0" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header"
|
|
||||||
value="true" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator"
|
|
||||||
value="true" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header"
|
|
||||||
value="true" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations"
|
|
||||||
value="1" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block"
|
|
||||||
value="true" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration"
|
|
||||||
value="16" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments"
|
|
||||||
value="true" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if"
|
|
||||||
value="16" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases"
|
|
||||||
value="true" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports"
|
|
||||||
value="1" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert"
|
|
||||||
value="insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_html"
|
|
||||||
value="true" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration"
|
|
||||||
value="16" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code"
|
|
||||||
value="true" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration"
|
|
||||||
value="16" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer"
|
|
||||||
value="insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform"
|
|
||||||
value="1.7" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try"
|
|
||||||
value="80" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations"
|
|
||||||
value="false" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation"
|
|
||||||
value="0" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_header"
|
|
||||||
value="false" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.comment.format_block_comments"
|
|
||||||
value="false" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants"
|
|
||||||
value="0" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header"
|
|
||||||
value="true" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration"
|
|
||||||
value="end_of_line" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries"
|
|
||||||
value="true" />
|
|
||||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports"
|
|
||||||
value="1" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header"
|
|
||||||
value="true" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for"
|
|
||||||
value="insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column"
|
|
||||||
value="false" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments"
|
|
||||||
value="do not insert" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column"
|
|
||||||
value="false" />
|
|
||||||
<setting
|
|
||||||
id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line"
|
|
||||||
value="false" />
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
3
pom.xml
3
pom.xml
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<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">
|
<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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.springframework.data</groupId>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
||||||
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
|
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
|
||||||
<book xmlns:xi="http://www.w3.org/2001/XInclude">
|
<book xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||||
<bookinfo>
|
<bookinfo>
|
||||||
<title>Spring Data Elasticsearch</title>
|
<title>Spring Data Elasticsearch</title>
|
||||||
@ -28,9 +28,9 @@
|
|||||||
</copyright>
|
</copyright>
|
||||||
</bookinfo>
|
</bookinfo>
|
||||||
|
|
||||||
<toc />
|
<toc/>
|
||||||
|
|
||||||
<xi:include href="preface.xml" />
|
<xi:include href="preface.xml"/>
|
||||||
|
|
||||||
<part id="reference">
|
<part id="reference">
|
||||||
<title>Reference Documentation</title>
|
<title>Reference Documentation</title>
|
||||||
@ -38,11 +38,11 @@
|
|||||||
<xi:include
|
<xi:include
|
||||||
href="https://raw.github.com/SpringSource/spring-data-commons/1.4.0.RC1/src/docbkx/repositories.xml">
|
href="https://raw.github.com/SpringSource/spring-data-commons/1.4.0.RC1/src/docbkx/repositories.xml">
|
||||||
<xi:fallback
|
<xi:fallback
|
||||||
href="../../../spring-data-commons/src/docbkx/repositories.xml" />
|
href="../../../spring-data-commons/src/docbkx/repositories.xml"/>
|
||||||
</xi:include>
|
</xi:include>
|
||||||
|
|
||||||
<xi:include href="reference/data-elasticsearch.xml" />
|
<xi:include href="reference/data-elasticsearch.xml"/>
|
||||||
<xi:include href="reference/elasticsearch-misc.xml" />
|
<xi:include href="reference/elasticsearch-misc.xml"/>
|
||||||
</part>
|
</part>
|
||||||
|
|
||||||
<part id="appendix">
|
<part id="appendix">
|
||||||
@ -50,12 +50,12 @@
|
|||||||
<xi:include
|
<xi:include
|
||||||
href="https://raw.github.com/SpringSource/spring-data-commons/1.4.0.RC1/src/docbkx/repository-namespace-reference.xml">
|
href="https://raw.github.com/SpringSource/spring-data-commons/1.4.0.RC1/src/docbkx/repository-namespace-reference.xml">
|
||||||
<xi:fallback
|
<xi:fallback
|
||||||
href="../../../spring-data-commons/src/docbkx/repository-namespace-reference.xml" />
|
href="../../../spring-data-commons/src/docbkx/repository-namespace-reference.xml"/>
|
||||||
</xi:include>
|
</xi:include>
|
||||||
<xi:include
|
<xi:include
|
||||||
href="https://raw.github.com/SpringSource/spring-data-commons/1.4.0.RC1/src/docbkx/repository-query-keywords-reference.xml">
|
href="https://raw.github.com/SpringSource/spring-data-commons/1.4.0.RC1/src/docbkx/repository-query-keywords-reference.xml">
|
||||||
<xi:fallback
|
<xi:fallback
|
||||||
href="../../../spring-data-commons/src/docbkx/repository-query-keywords-reference.xml" />
|
href="../../../spring-data-commons/src/docbkx/repository-query-keywords-reference.xml"/>
|
||||||
</xi:include>
|
</xi:include>
|
||||||
</part>
|
</part>
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE preface PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
<!DOCTYPE preface PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
||||||
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
|
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
|
||||||
<preface id="preface">
|
<preface id="preface">
|
||||||
<title>Preface</title>
|
<title>Preface</title>
|
||||||
<para>The Spring Data Elasticsearch project applies core Spring
|
<para>The Spring Data Elasticsearch project applies core Spring
|
||||||
@ -21,7 +21,8 @@
|
|||||||
<para>
|
<para>
|
||||||
Version Control -
|
Version Control -
|
||||||
<ulink
|
<ulink
|
||||||
url="git://github.com/BioMedCentralLtd/spring-data-elasticsearch.git">git://github.com/BioMedCentralLtd/spring-data-elasticsearch.git
|
url="git://github.com/BioMedCentralLtd/spring-data-elasticsearch.git">
|
||||||
|
git://github.com/BioMedCentralLtd/spring-data-elasticsearch.git
|
||||||
</ulink>
|
</ulink>
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
||||||
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
|
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
|
||||||
<chapter id="elasticsearch.repositories">
|
<chapter id="elasticsearch.repositories">
|
||||||
<title>Elasticsearch Repositories</title>
|
<title>Elasticsearch Repositories</title>
|
||||||
<abstract>
|
<abstract>
|
||||||
@ -28,23 +28,23 @@
|
|||||||
Using the
|
Using the
|
||||||
<code>repositories</code>
|
<code>repositories</code>
|
||||||
element looks up Spring Data repositories as described in
|
element looks up Spring Data repositories as described in
|
||||||
<xref linkend="repositories.create-instances" />
|
<xref linkend="repositories.create-instances"/>
|
||||||
.
|
.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<example>
|
<example>
|
||||||
<title>Setting up Elasticsearch repositories using Namespace</title>
|
<title>Setting up Elasticsearch repositories using Namespace</title>
|
||||||
<programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?>
|
<programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?>
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:elasticsearch="http://www.springframework.org/schema/data/elasticsearch"
|
xmlns:elasticsearch="http://www.springframework.org/schema/data/elasticsearch"
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||||
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||||
http://www.springframework.org/schema/data/elasticsearch
|
http://www.springframework.org/schema/data/elasticsearch
|
||||||
http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch-1.0.xsd">
|
http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch-1.0.xsd">
|
||||||
|
|
||||||
<elasticsearch:repositories base-package="com.acme.repositories" />
|
<elasticsearch:repositories base-package="com.acme.repositories" />
|
||||||
</beans></programlisting>
|
</beans></programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -59,31 +59,31 @@ http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch-1.
|
|||||||
<example>
|
<example>
|
||||||
<title>Transport Client using Namespace</title>
|
<title>Transport Client using Namespace</title>
|
||||||
<programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?>
|
<programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?>
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:elasticsearch="http://www.springframework.org/schema/data/elasticsearch"
|
xmlns:elasticsearch="http://www.springframework.org/schema/data/elasticsearch"
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||||
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||||
http://www.springframework.org/schema/data/elasticsearch
|
http://www.springframework.org/schema/data/elasticsearch
|
||||||
http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch-1.0.xsd">
|
http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch-1.0.xsd">
|
||||||
|
|
||||||
<elasticsearch:transport-client id="client" cluster-nodes="localhost:9300,someip:9300" />
|
<elasticsearch:transport-client id="client" cluster-nodes="localhost:9300,someip:9300" />
|
||||||
</beans> </programlisting>
|
</beans> </programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
<example>
|
<example>
|
||||||
<title>Node Client using Namespace</title>
|
<title>Node Client using Namespace</title>
|
||||||
<programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?>
|
<programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?>
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:elasticsearch="http://www.springframework.org/schema/data/elasticsearch"
|
xmlns:elasticsearch="http://www.springframework.org/schema/data/elasticsearch"
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||||
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||||||
http://www.springframework.org/schema/data/elasticsearch
|
http://www.springframework.org/schema/data/elasticsearch
|
||||||
http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch-1.0.xsd">
|
http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch-1.0.xsd">
|
||||||
|
|
||||||
<elasticsearch:node-client id="client" local="true"" />
|
<elasticsearch:node-client id="client" local="true"" />
|
||||||
</beans> </programlisting>
|
</beans> </programlisting>
|
||||||
</example>
|
</example>
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
@ -98,15 +98,17 @@ http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch-1.
|
|||||||
<title>Spring Data Elasticsearch repositories using JavaConfig
|
<title>Spring Data Elasticsearch repositories using JavaConfig
|
||||||
</title>
|
</title>
|
||||||
<programlisting language="java">
|
<programlisting language="java">
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableElasticsearchRepositories(basePackages = "org/springframework/data/elasticsearch/repositories")
|
@EnableElasticsearchRepositories(basePackages =
|
||||||
static class Config {
|
"org/springframework/data/elasticsearch/repositories")
|
||||||
|
static class Config {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ElasticsearchOperations elasticsearchTemplate() {
|
public ElasticsearchOperations elasticsearchTemplate() {
|
||||||
return new ElasticsearchTemplate(nodeBuilder().local(true).node().client());
|
return new ElasticsearchTemplate(nodeBuilder().local(true).node().client());
|
||||||
}
|
}
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
<para>
|
<para>
|
||||||
The configuration above sets up an
|
The configuration above sets up an
|
||||||
<classname>Embedded Elasticsearch Server</classname>
|
<classname>Embedded Elasticsearch Server</classname>
|
||||||
@ -135,26 +137,27 @@ return new ElasticsearchTemplate(nodeBuilder().local(true).node().client());
|
|||||||
</title>
|
</title>
|
||||||
<programlisting language="java">class ElasticsearchTemplateProducer {
|
<programlisting language="java">class ElasticsearchTemplateProducer {
|
||||||
|
|
||||||
@Produces
|
@Produces
|
||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
public ElasticsearchOperations createElasticsearchTemplate() {
|
public ElasticsearchOperations createElasticsearchTemplate() {
|
||||||
return new ElasticsearchTemplate(nodeBuilder().local(true).node().client());
|
return new ElasticsearchTemplate(nodeBuilder().local(true).node().client());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProductService {
|
class ProductService {
|
||||||
|
|
||||||
private ProductRepository repository;
|
private ProductRepository repository;
|
||||||
|
|
||||||
public Page<Product> findAvailableBookByName(String name, Pageable pageable) {
|
public Page<Product> findAvailableBookByName(String name, Pageable pageable) {
|
||||||
return repository.findByAvailableTrueAndNameStartingWith(name, pageable);
|
return repository.findByAvailableTrueAndNameStartingWith(name, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public void setRepository(ProductRepository repository) {
|
public void setRepository(ProductRepository repository) {
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
}
|
}
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
@ -178,7 +181,7 @@ public void setRepository(ProductRepository repository) {
|
|||||||
might make either use of
|
might make either use of
|
||||||
<interfacename>@Query</interfacename>
|
<interfacename>@Query</interfacename>
|
||||||
annotation (see
|
annotation (see
|
||||||
<xref linkend="elasticsearch.query-methods.at-query" />
|
<xref linkend="elasticsearch.query-methods.at-query"/>
|
||||||
).
|
).
|
||||||
</para>
|
</para>
|
||||||
</simplesect>
|
</simplesect>
|
||||||
@ -191,15 +194,17 @@ public void setRepository(ProductRepository repository) {
|
|||||||
Generally the query creation mechanism for Elasticsearch works as
|
Generally the query creation mechanism for Elasticsearch works as
|
||||||
described
|
described
|
||||||
in
|
in
|
||||||
<xref linkend="repositories.query-methods" />
|
<xref linkend="repositories.query-methods"/>
|
||||||
. Here's a short example
|
. Here's a short example
|
||||||
of what a Elasticsearch query method
|
of what a Elasticsearch query method
|
||||||
translates into:
|
translates into:
|
||||||
<example>
|
<example>
|
||||||
<title>Query creation from method names</title>
|
<title>Query creation from method names</title>
|
||||||
<programlisting language="java">public interface BookRepository extends Repository<Book, String> {
|
<programlisting language="java">public interface BookRepository extends Repository<Book, String>
|
||||||
|
{
|
||||||
List<Book> findByNameAndPrice(String name, Integer price);
|
List<Book> findByNameAndPrice(String name, Integer price);
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
<para>
|
<para>
|
||||||
The method name above will be translated into the following
|
The method name above will be translated into the following
|
||||||
Elasticsearch json query
|
Elasticsearch json query
|
||||||
@ -210,7 +215,8 @@ public void setRepository(ProductRepository repository) {
|
|||||||
[
|
[
|
||||||
{ "field" : {"name" : "?"} },
|
{ "field" : {"name" : "?"} },
|
||||||
{ "field" : {"price" : "?"} }
|
{ "field" : {"price" : "?"} }
|
||||||
] } }</programlisting>
|
] } }
|
||||||
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
@ -218,9 +224,9 @@ public void setRepository(ProductRepository repository) {
|
|||||||
<table>
|
<table>
|
||||||
<title>Supported keywords inside method names</title>
|
<title>Supported keywords inside method names</title>
|
||||||
<tgroup cols="3">
|
<tgroup cols="3">
|
||||||
<colspec colwidth="1*" />
|
<colspec colwidth="1*"/>
|
||||||
<colspec colwidth="2*" />
|
<colspec colwidth="2*"/>
|
||||||
<colspec colwidth="3*" />
|
<colspec colwidth="3*"/>
|
||||||
<thead>
|
<thead>
|
||||||
<row>
|
<row>
|
||||||
<entry>Keyword</entry>
|
<entry>Keyword</entry>
|
||||||
@ -238,7 +244,8 @@ public void setRepository(ProductRepository repository) {
|
|||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<code>{"bool" : {"must" : [ {"field" : {"name" : "?"}},
|
<code>{"bool" : {"must" : [ {"field" : {"name" : "?"}},
|
||||||
{"field" : {"price" : "?"}} ]}}</code>
|
{"field" : {"price" : "?"}} ]}}
|
||||||
|
</code>
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
@ -250,7 +257,8 @@ public void setRepository(ProductRepository repository) {
|
|||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<code>{"bool" : {"should" : [ {"field" : {"name" : "?"}},
|
<code>{"bool" : {"should" : [ {"field" : {"name" : "?"}},
|
||||||
{"field" : {"price" : "?"}} ]}}</code>
|
{"field" : {"price" : "?"}} ]}}
|
||||||
|
</code>
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
@ -299,7 +307,8 @@ public void setRepository(ProductRepository repository) {
|
|||||||
<entry>
|
<entry>
|
||||||
<code>{"bool" : {"must" : {"range" : {"price" : {"from" :
|
<code>{"bool" : {"must" : {"range" : {"price" : {"from" :
|
||||||
null,"to" : ?,"include_lower" : true,"include_upper" :
|
null,"to" : ?,"include_lower" : true,"include_upper" :
|
||||||
true}}}}}</code>
|
true}}}}}
|
||||||
|
</code>
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
@ -312,7 +321,8 @@ public void setRepository(ProductRepository repository) {
|
|||||||
<entry>
|
<entry>
|
||||||
<code>{"bool" : {"must" : {"range" : {"price" : {"from" :
|
<code>{"bool" : {"must" : {"range" : {"price" : {"from" :
|
||||||
?,"to" : null,"include_lower" : true,"include_upper" :
|
?,"to" : null,"include_lower" : true,"include_upper" :
|
||||||
true}}}}}</code>
|
true}}}}}
|
||||||
|
</code>
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
@ -325,7 +335,8 @@ public void setRepository(ProductRepository repository) {
|
|||||||
<entry>
|
<entry>
|
||||||
<code>{"bool" : {"must" : {"range" : {"price" : {"from" :
|
<code>{"bool" : {"must" : {"range" : {"price" : {"from" :
|
||||||
null,"to" : ?,"include_lower" : true,"include_upper" :
|
null,"to" : ?,"include_lower" : true,"include_upper" :
|
||||||
true}}}}}</code>
|
true}}}}}
|
||||||
|
</code>
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
@ -338,7 +349,8 @@ public void setRepository(ProductRepository repository) {
|
|||||||
<entry>
|
<entry>
|
||||||
<code>{"bool" : {"must" : {"range" : {"price" : {"from" :
|
<code>{"bool" : {"must" : {"range" : {"price" : {"from" :
|
||||||
?,"to" : null,"include_lower" : true,"include_upper" :
|
?,"to" : null,"include_lower" : true,"include_upper" :
|
||||||
true}}}}}</code>
|
true}}}}}
|
||||||
|
</code>
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
@ -350,7 +362,8 @@ public void setRepository(ProductRepository repository) {
|
|||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<code>{"bool" : {"must" : {"field" : {"name" : {"query" :
|
<code>{"bool" : {"must" : {"field" : {"name" : {"query" :
|
||||||
"?*","analyze_wildcard" : true}}}}}</code>
|
"?*","analyze_wildcard" : true}}}}}
|
||||||
|
</code>
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
@ -362,7 +375,8 @@ public void setRepository(ProductRepository repository) {
|
|||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<code>{"bool" : {"must" : {"field" : {"name" : {"query" :
|
<code>{"bool" : {"must" : {"field" : {"name" : {"query" :
|
||||||
"?*","analyze_wildcard" : true}}}}}</code>
|
"?*","analyze_wildcard" : true}}}}}
|
||||||
|
</code>
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
@ -374,7 +388,8 @@ public void setRepository(ProductRepository repository) {
|
|||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<code>{"bool" : {"must" : {"field" : {"name" : {"query" :
|
<code>{"bool" : {"must" : {"field" : {"name" : {"query" :
|
||||||
"*?","analyze_wildcard" : true}}}}}</code>
|
"*?","analyze_wildcard" : true}}}}}
|
||||||
|
</code>
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
@ -386,7 +401,8 @@ public void setRepository(ProductRepository repository) {
|
|||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<code>{"bool" : {"must" : {"field" : {"name" : {"query" :
|
<code>{"bool" : {"must" : {"field" : {"name" : {"query" :
|
||||||
"*?*","analyze_wildcard" : true}}}}}</code>
|
"*?*","analyze_wildcard" : true}}}}}
|
||||||
|
</code>
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
@ -398,7 +414,8 @@ public void setRepository(ProductRepository repository) {
|
|||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<code>{"bool" : {"must" : {"bool" : {"should" : [ {"field" :
|
<code>{"bool" : {"must" : {"bool" : {"should" : [ {"field" :
|
||||||
{"name" : "?"}}, {"field" : {"name" : "?"}} ]}}}}</code>
|
{"name" : "?"}}, {"field" : {"name" : "?"}} ]}}}}
|
||||||
|
</code>
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
@ -410,7 +427,8 @@ public void setRepository(ProductRepository repository) {
|
|||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<code>{"bool" : {"must_not" : {"bool" : {"should" : {"field" :
|
<code>{"bool" : {"must_not" : {"bool" : {"should" : {"field" :
|
||||||
{"name" : "?"}}}}}}</code>
|
{"name" : "?"}}}}}}
|
||||||
|
</code>
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
@ -457,7 +475,8 @@ public void setRepository(ProductRepository repository) {
|
|||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<code>{"sort" : [{ "name" : {"order" : "desc"} }],"bool" :
|
<code>{"sort" : [{ "name" : {"order" : "desc"} }],"bool" :
|
||||||
{"must" : {"field" : {"available" : true}}}}</code>
|
{"must" : {"field" : {"available" : true}}}}
|
||||||
|
</code>
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -474,10 +493,12 @@ public void setRepository(ProductRepository repository) {
|
|||||||
annotation.
|
annotation.
|
||||||
</title>
|
</title>
|
||||||
|
|
||||||
<programlisting language="java">public interface BookRepository extends ElasticsearchRepository<Book, String> {
|
<programlisting language="java">public interface BookRepository extends ElasticsearchRepository<Book,
|
||||||
|
String> {
|
||||||
@Query("{"bool" : {"must" : {"field" : {"name" : "?0"}}}}")
|
@Query("{"bool" : {"must" : {"field" : {"name" : "?0"}}}}")
|
||||||
Page<Book> findByName(String name,Pageable pageable);
|
Page<Book> findByName(String name,Pageable pageable);
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
||||||
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
|
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
|
||||||
<chapter id="elasticsearch.misc">
|
<chapter id="elasticsearch.misc">
|
||||||
<title>Miscellaneous Elasticsearch Operation Support</title>
|
<title>Miscellaneous Elasticsearch Operation Support</title>
|
||||||
<abstract>
|
<abstract>
|
||||||
@ -12,7 +12,7 @@
|
|||||||
recommended to add those operations as custom
|
recommended to add those operations as custom
|
||||||
implementation as
|
implementation as
|
||||||
described in
|
described in
|
||||||
<xref linkend="repositories.custom-implementations" />
|
<xref linkend="repositories.custom-implementations"/>
|
||||||
.
|
.
|
||||||
</para>
|
</para>
|
||||||
</abstract>
|
</abstract>
|
||||||
@ -23,13 +23,14 @@
|
|||||||
</para>
|
</para>
|
||||||
<example>
|
<example>
|
||||||
<programlisting language="java">
|
<programlisting language="java">
|
||||||
private ElasticsearchTemplate elasticsearchTemplate;
|
private ElasticsearchTemplate elasticsearchTemplate;
|
||||||
SearchQuery searchQuery = new NativeSearchQueryBuilder()
|
SearchQuery searchQuery = new NativeSearchQueryBuilder()
|
||||||
.withQuery(matchAllQuery())
|
.withQuery(matchAllQuery())
|
||||||
.withFilter(boolFilter().must(termFilter("id", documentId)))
|
.withFilter(boolFilter().must(termFilter("id", documentId)))
|
||||||
.build();
|
.build();
|
||||||
Page<SampleEntity> sampleEntities = elasticsearchTemplate.queryForPage(searchQuery,SampleEntity.class);
|
Page<SampleEntity> sampleEntities =
|
||||||
</programlisting>
|
elasticsearchTemplate.queryForPage(searchQuery,SampleEntity.class);
|
||||||
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</section>
|
</section>
|
||||||
<section id="elasticsearch.scan.and.scroll">
|
<section id="elasticsearch.scan.and.scroll">
|
||||||
@ -45,21 +46,22 @@ Page<SampleEntity> sampleEntities = elasticsearchTemplate.queryForPage(sea
|
|||||||
Using Scan and Scroll
|
Using Scan and Scroll
|
||||||
</title>
|
</title>
|
||||||
<programlisting language="java">
|
<programlisting language="java">
|
||||||
SearchQuery searchQuery = new NativeSearchQueryBuilder()
|
SearchQuery searchQuery = new NativeSearchQueryBuilder()
|
||||||
.withQuery(matchAllQuery())
|
.withQuery(matchAllQuery())
|
||||||
.withIndices("test-index")
|
.withIndices("test-index")
|
||||||
.withTypes("test-type")
|
.withTypes("test-type")
|
||||||
.withPageable(new PageRequest(0,1))
|
.withPageable(new PageRequest(0,1))
|
||||||
.build();
|
.build();
|
||||||
String scrollId = elasticsearchTemplate.scan(searchQuery,1000,false);
|
String scrollId = elasticsearchTemplate.scan(searchQuery,1000,false);
|
||||||
List<SampleEntity> sampleEntities = new ArrayList<SampleEntity>();
|
List<SampleEntity> sampleEntities = new ArrayList<SampleEntity>();
|
||||||
boolean hasRecords = true;
|
boolean hasRecords = true;
|
||||||
while (hasRecords){
|
while (hasRecords){
|
||||||
Page<SampleEntity> page = elasticsearchTemplate.scroll(scrollId, 5000L , new ResultsMapper<SampleEntity>() {
|
Page<SampleEntity> page = elasticsearchTemplate.scroll(scrollId, 5000L , new ResultsMapper<SampleEntity>()
|
||||||
@Override
|
{
|
||||||
public Page<SampleEntity> mapResults(SearchResponse response) {
|
@Override
|
||||||
List<SampleEntity> chunk = new ArrayList<SampleEntity>();
|
public Page<SampleEntity> mapResults(SearchResponse response) {
|
||||||
for(SearchHit searchHit : response.getHits()){
|
List<SampleEntity> chunk = new ArrayList<SampleEntity>();
|
||||||
|
for(SearchHit searchHit : response.getHits()){
|
||||||
if(response.getHits().getHits().length <= 0) {
|
if(response.getHits().getHits().length <= 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -69,7 +71,7 @@ for(SearchHit searchHit : response.getHits()){
|
|||||||
chunk.add(user);
|
chunk.add(user);
|
||||||
}
|
}
|
||||||
return new PageImpl<SampleEntity>(chunk);
|
return new PageImpl<SampleEntity>(chunk);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(page != null) {
|
if(page != null) {
|
||||||
sampleEntities.addAll(page.getContent());
|
sampleEntities.addAll(page.getContent());
|
||||||
@ -79,7 +81,8 @@ for(SearchHit searchHit : response.getHits()){
|
|||||||
hasRecords = false;
|
hasRecords = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</section>
|
</section>
|
||||||
</chapter>
|
</chapter>
|
@ -71,17 +71,17 @@
|
|||||||
|
|
||||||
<programlistingco>
|
<programlistingco>
|
||||||
<areaspec>
|
<areaspec>
|
||||||
<area coords="3" id="repository.save" />
|
<area coords="3" id="repository.save"/>
|
||||||
|
|
||||||
<area coords="5" id="repository.find-by-id" />
|
<area coords="5" id="repository.find-by-id"/>
|
||||||
|
|
||||||
<area coords="7" id="repository.find-all" />
|
<area coords="7" id="repository.find-all"/>
|
||||||
|
|
||||||
<area coords="11" id="repository.count" />
|
<area coords="11" id="repository.count"/>
|
||||||
|
|
||||||
<area coords="13" id="repository.delete" />
|
<area coords="13" id="repository.delete"/>
|
||||||
|
|
||||||
<area coords="15" id="repository.exists" />
|
<area coords="15" id="repository.exists"/>
|
||||||
</areaspec>
|
</areaspec>
|
||||||
|
|
||||||
<programlisting language="java">public interface CrudRepository<T, ID extends Serializable>
|
<programlisting language="java">public interface CrudRepository<T, ID extends Serializable>
|
||||||
@ -100,7 +100,8 @@
|
|||||||
boolean exists(ID primaryKey);
|
boolean exists(ID primaryKey);
|
||||||
|
|
||||||
// … more functionality omitted.
|
// … more functionality omitted.
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
<calloutlist>
|
<calloutlist>
|
||||||
<callout arearefs="repository.save">
|
<callout arearefs="repository.save">
|
||||||
@ -151,12 +152,14 @@
|
|||||||
<example>
|
<example>
|
||||||
<title>PagingAndSortingRepository</title>
|
<title>PagingAndSortingRepository</title>
|
||||||
|
|
||||||
<programlisting language="java">public interface PagingAndSortingRepository<T, ID extends Serializable> extends CrudRepository<T, ID> {
|
<programlisting language="java">public interface PagingAndSortingRepository<T, ID extends Serializable>
|
||||||
|
extends CrudRepository<T, ID> {
|
||||||
|
|
||||||
Iterable<T> findAll(Sort sort);
|
Iterable<T> findAll(Sort sort);
|
||||||
|
|
||||||
Page<T> findAll(Pageable pageable);
|
Page<T> findAll(Pageable pageable);
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -166,8 +169,10 @@
|
|||||||
size of 20 you could simply do something like this:
|
size of 20 you could simply do something like this:
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<programlisting language="java">PagingAndSortingRepository<User, Long> repository = // … get access to a bean
|
<programlisting language="java">PagingAndSortingRepository<User, Long> repository = // … get access to a
|
||||||
Page<User> users = repository.findAll(new PageRequest(1, 20));</programlisting>
|
bean
|
||||||
|
Page<User> users = repository.findAll(new PageRequest(1, 20));
|
||||||
|
</programlisting>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section id="repositories.query-methods">
|
<section id="repositories.query-methods">
|
||||||
@ -188,7 +193,9 @@
|
|||||||
and type it to the domain class it shall handle.
|
and type it to the domain class it shall handle.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<programlisting language="java">public interface PersonRepository extends Repository<User, Long> { … }</programlisting>
|
<programlisting language="java">public interface PersonRepository extends Repository<User, Long> {
|
||||||
|
… }
|
||||||
|
</programlisting>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
@ -240,7 +247,8 @@
|
|||||||
|
|
||||||
public void doSomething() {
|
public void doSomething() {
|
||||||
List<Person> persons = repository.findByLastname("Matthews");
|
List<Person> persons = repository.findByLastname("Matthews");
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
</listitem>
|
</listitem>
|
||||||
</orderedlist>
|
</orderedlist>
|
||||||
|
|
||||||
@ -295,7 +303,8 @@
|
|||||||
<example>
|
<example>
|
||||||
<title>Selectively exposing CRUD methods</title>
|
<title>Selectively exposing CRUD methods</title>
|
||||||
|
|
||||||
<programlisting language="java">interface MyBaseRepository<T, ID extends Serializable> extends Repository<T, ID> {
|
<programlisting language="java">interface MyBaseRepository<T, ID extends Serializable> extends
|
||||||
|
Repository<T, ID> {
|
||||||
T findOne(ID id);
|
T findOne(ID id);
|
||||||
T save(T entity);
|
T save(T entity);
|
||||||
}
|
}
|
||||||
@ -303,7 +312,8 @@
|
|||||||
interface UserRepository extends MyBaseRepository<User, Long> {
|
interface UserRepository extends MyBaseRepository<User, Long> {
|
||||||
|
|
||||||
User findByEmailAddress(EmailAddress emailAddress);
|
User findByEmailAddress(EmailAddress emailAddress);
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -364,7 +374,7 @@
|
|||||||
given set of well-known prefixes from the method name and parse
|
given set of well-known prefixes from the method name and parse
|
||||||
the
|
the
|
||||||
rest of the method. Read more about query construction in
|
rest of the method. Read more about query construction in
|
||||||
<xref linkend="repositories.query-methods.query-creation" />
|
<xref linkend="repositories.query-methods.query-creation"/>
|
||||||
.
|
.
|
||||||
</para>
|
</para>
|
||||||
</simplesect>
|
</simplesect>
|
||||||
@ -434,10 +444,13 @@
|
|||||||
<title>Query creation from method names</title>
|
<title>Query creation from method names</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
<programlisting language="java">public interface PersonRepository extends Repository<User, Long> {
|
<programlisting language="java">public interface PersonRepository extends Repository<User,
|
||||||
|
Long> {
|
||||||
|
|
||||||
List<Person> findByEmailAddressAndLastname(EmailAddress emailAddress, String lastname);
|
List<Person> findByEmailAddressAndLastname(EmailAddress emailAddress, String
|
||||||
}</programlisting>
|
lastname);
|
||||||
|
}
|
||||||
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
@ -482,7 +495,8 @@
|
|||||||
of
|
of
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<programlisting language="java">List<Person> findByAddressZipCode(ZipCode zipCode);</programlisting>
|
<programlisting language="java">List<Person> findByAddressZipCode(ZipCode zipCode);
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
will create the property traversal
|
will create the property traversal
|
||||||
@ -551,7 +565,8 @@
|
|||||||
|
|
||||||
List<User> findByLastname(String lastname, Sort sort);
|
List<User> findByLastname(String lastname, Sort sort);
|
||||||
|
|
||||||
List<User> findByLastname(String lastname, Pageable pageable);</programlisting>
|
List<User> findByLastname(String lastname, Pageable pageable);
|
||||||
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -665,7 +680,8 @@
|
|||||||
details see
|
details see
|
||||||
<ulink
|
<ulink
|
||||||
url="http://static.springsource.org/spring/docs/2.5.x/reference/beans.html#beans-scanning-filters"
|
url="http://static.springsource.org/spring/docs/2.5.x/reference/beans.html#beans-scanning-filters"
|
||||||
vendor="">Spring reference documentation</ulink>
|
vendor="">Spring reference documentation
|
||||||
|
</ulink>
|
||||||
on these
|
on these
|
||||||
elements.
|
elements.
|
||||||
</para>
|
</para>
|
||||||
@ -706,7 +722,7 @@
|
|||||||
<para>
|
<para>
|
||||||
JavaConfig in the Spring reference documentation -
|
JavaConfig in the Spring reference documentation -
|
||||||
<ulink
|
<ulink
|
||||||
url="http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/beans.html#beans-java" />
|
url="http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/beans.html#beans-java"/>
|
||||||
</para>
|
</para>
|
||||||
</footnote>
|
</footnote>
|
||||||
</para>
|
</para>
|
||||||
@ -727,7 +743,8 @@
|
|||||||
public EntityManagerFactory entityManagerFactory() {
|
public EntityManagerFactory entityManagerFactory() {
|
||||||
// …
|
// …
|
||||||
}
|
}
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -759,7 +776,8 @@
|
|||||||
<title>Standalone usage of repository factory</title>
|
<title>Standalone usage of repository factory</title>
|
||||||
|
|
||||||
<programlisting language="java">RepositoryFactorySupport factory = … // Instantiate factory here
|
<programlisting language="java">RepositoryFactorySupport factory = … // Instantiate factory here
|
||||||
UserRepository repository = factory.getRepository(UserRepository.class);</programlisting>
|
UserRepository repository = factory.getRepository(UserRepository.class);
|
||||||
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
@ -789,7 +807,8 @@
|
|||||||
<programlisting language="java">interface UserRepositoryCustom {
|
<programlisting language="java">interface UserRepositoryCustom {
|
||||||
|
|
||||||
public void someCustomMethod(User user);
|
public void someCustomMethod(User user);
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
<example>
|
<example>
|
||||||
@ -801,7 +820,8 @@
|
|||||||
public void someCustomMethod(User user) {
|
public void someCustomMethod(User user) {
|
||||||
// Your custom implementation
|
// Your custom implementation
|
||||||
}
|
}
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
Note that the implementation itself does not depend on
|
Note that the implementation itself does not depend on
|
||||||
Spring Data and can be a regular Spring bean. So you can use standard
|
Spring Data and can be a regular Spring bean. So you can use standard
|
||||||
dependency injection behaviour to inject references to other beans,
|
dependency injection behaviour to inject references to other beans,
|
||||||
@ -813,10 +833,12 @@
|
|||||||
<title>Changes to the your basic repository interface</title>
|
<title>Changes to the your basic repository interface</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
<programlisting language="java">public interface UserRepository extends CrudRepository<User, Long>, UserRepositoryCustom {
|
<programlisting language="java">public interface UserRepository extends CrudRepository<User, Long>,
|
||||||
|
UserRepositoryCustom {
|
||||||
|
|
||||||
// Declare query methods here
|
// Declare query methods here
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
Let your standard repository interface extend the custom
|
Let your standard repository interface extend the custom
|
||||||
one. This makes CRUD and custom functionality available to
|
one. This makes CRUD and custom functionality available to
|
||||||
clients.
|
clients.
|
||||||
@ -844,7 +866,8 @@
|
|||||||
<para>
|
<para>
|
||||||
<programlisting language="xml"><repositories base-package="com.acme.repository" />
|
<programlisting language="xml"><repositories base-package="com.acme.repository" />
|
||||||
|
|
||||||
<repositories base-package="com.acme.repository" repository-impl-postfix="FooBar" /></programlisting>
|
<repositories base-package="com.acme.repository" repository-impl-postfix="FooBar"
|
||||||
|
/></programlisting>
|
||||||
</para>
|
</para>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
@ -904,7 +927,8 @@
|
|||||||
extends JpaRepository<T, ID> {
|
extends JpaRepository<T, ID> {
|
||||||
|
|
||||||
void sharedCustomMethod(ID id);
|
void sharedCustomMethod(ID id);
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
</para>
|
</para>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
@ -969,7 +993,8 @@
|
|||||||
public void sharedCustomMethod(ID id) {
|
public void sharedCustomMethod(ID id) {
|
||||||
// implementation goes here
|
// implementation goes here
|
||||||
}
|
}
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -994,7 +1019,8 @@
|
|||||||
<title>Custom repository factory bean</title>
|
<title>Custom repository factory bean</title>
|
||||||
|
|
||||||
<programlisting language="java">
|
<programlisting language="java">
|
||||||
public class MyRepositoryFactoryBean<R extends JpaRepository<T, I>, T, I extends Serializable>
|
public class MyRepositoryFactoryBean<R extends JpaRepository<T, I>, T, I extends
|
||||||
|
Serializable>
|
||||||
extends JpaRepositoryFactoryBean<R, T, I> {
|
extends JpaRepositoryFactoryBean<R, T, I> {
|
||||||
|
|
||||||
protected RepositoryFactorySupport createRepositoryFactory(EntityManager entityManager) {
|
protected RepositoryFactorySupport createRepositoryFactory(EntityManager entityManager) {
|
||||||
@ -1002,7 +1028,8 @@
|
|||||||
return new MyRepositoryFactory(entityManager);
|
return new MyRepositoryFactory(entityManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class MyRepositoryFactory<T, I extends Serializable> extends JpaRepositoryFactory {
|
private static class MyRepositoryFactory<T, I extends Serializable> extends
|
||||||
|
JpaRepositoryFactory {
|
||||||
|
|
||||||
private EntityManager entityManager;
|
private EntityManager entityManager;
|
||||||
|
|
||||||
@ -1024,7 +1051,8 @@
|
|||||||
return MyRepository.class;
|
return MyRepository.class;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -1085,7 +1113,8 @@
|
|||||||
// Populate model
|
// Populate model
|
||||||
return "user";
|
return "user";
|
||||||
}
|
}
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
First you pretty much have to declare a repository dependency for
|
First you pretty much have to declare a repository dependency for
|
||||||
@ -1119,7 +1148,8 @@
|
|||||||
domain class
|
domain class
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<programlisting language="xml"><bean class="….web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
|
<programlisting language="xml"><bean
|
||||||
|
class="….web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
|
||||||
<property name="webBindingInitializer">
|
<property name="webBindingInitializer">
|
||||||
<bean class="….web.bind.support.ConfigurableWebBindingInitializer">
|
<bean class="….web.bind.support.ConfigurableWebBindingInitializer">
|
||||||
<property name="propertyEditorRegistrars">
|
<property name="propertyEditorRegistrars">
|
||||||
@ -1145,7 +1175,8 @@
|
|||||||
// Populate model
|
// Populate model
|
||||||
return "userForm";
|
return "userForm";
|
||||||
}
|
}
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
</simplesect>
|
</simplesect>
|
||||||
|
|
||||||
<simplesect>
|
<simplesect>
|
||||||
@ -1202,7 +1233,8 @@
|
|||||||
model.addAttribute("users", userService.getUsers(pageable));
|
model.addAttribute("users", userService.getUsers(pageable));
|
||||||
return "users";
|
return "users";
|
||||||
}
|
}
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
As you can see the naive approach requires the method to contain
|
As you can see the naive approach requires the method to contain
|
||||||
@ -1241,7 +1273,8 @@
|
|||||||
model.addAttribute("users", userDao.readAll(pageable));
|
model.addAttribute("users", userDao.readAll(pageable));
|
||||||
return "users";
|
return "users";
|
||||||
}
|
}
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The
|
The
|
||||||
@ -1260,9 +1293,9 @@
|
|||||||
</title>
|
</title>
|
||||||
|
|
||||||
<tgroup cols="2">
|
<tgroup cols="2">
|
||||||
<colspec colwidth="1*" />
|
<colspec colwidth="1*"/>
|
||||||
|
|
||||||
<colspec colwidth="2*" />
|
<colspec colwidth="2*"/>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<row>
|
<row>
|
||||||
@ -1386,7 +1419,8 @@
|
|||||||
"lastname" : "Matthews" },
|
"lastname" : "Matthews" },
|
||||||
{ "_class" : "com.acme.Person",
|
{ "_class" : "com.acme.Person",
|
||||||
"firstname" : "Carter",
|
"firstname" : "Carter",
|
||||||
"lastname" : "Beauford" } ]</programlisting>
|
"lastname" : "Beauford" } ]
|
||||||
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -1452,7 +1486,8 @@
|
|||||||
http://www.springframework.org/schema/oxm
|
http://www.springframework.org/schema/oxm
|
||||||
http://www.springframework.org/schema/oxm/spring-oxm.xsd">
|
http://www.springframework.org/schema/oxm/spring-oxm.xsd">
|
||||||
|
|
||||||
<repository:unmarshaller-populator location="classpath:data.json" unmarshaller-ref="unmarshaller" />
|
<repository:unmarshaller-populator location="classpath:data.json" unmarshaller-ref="unmarshaller"
|
||||||
|
/>
|
||||||
|
|
||||||
<oxm:jaxb2-marshaller contextPath="com.acme" />
|
<oxm:jaxb2-marshaller contextPath="com.acme" />
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ package org.springframework.data.elasticsearch.annotations;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jakub Vavrik
|
* @author Jakub Vavrik
|
||||||
*
|
|
||||||
* Values based on reference doc - http://www.elasticsearch.org/guide/reference/mapping/date-format/
|
* Values based on reference doc - http://www.elasticsearch.org/guide/reference/mapping/date-format/
|
||||||
*/
|
*/
|
||||||
public enum DateFormat {
|
public enum DateFormat {
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.annotations;
|
package org.springframework.data.elasticsearch.annotations;
|
||||||
|
|
||||||
import org.springframework.data.annotation.Persistent;
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
import org.springframework.data.annotation.Persistent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Document
|
* Document
|
||||||
*
|
*
|
||||||
@ -29,7 +29,7 @@ import java.lang.annotation.*;
|
|||||||
@Persistent
|
@Persistent
|
||||||
@Inherited
|
@Inherited
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ ElementType.TYPE })
|
@Target({ElementType.TYPE})
|
||||||
public @interface Document {
|
public @interface Document {
|
||||||
|
|
||||||
String indexName();
|
String indexName();
|
||||||
|
@ -43,6 +43,5 @@ public @interface Field {
|
|||||||
|
|
||||||
String indexAnalyzer() default "";
|
String indexAnalyzer() default "";
|
||||||
|
|
||||||
String [] ignoreFields() default {};
|
String[] ignoreFields() default {};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,5 +30,6 @@ import org.springframework.data.annotation.Persistent;
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.FIELD)
|
@Target(ElementType.FIELD)
|
||||||
public @interface Parent {
|
public @interface Parent {
|
||||||
|
|
||||||
String type();
|
String type();
|
||||||
}
|
}
|
||||||
|
@ -42,5 +42,4 @@ public @interface Query {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String name() default "";
|
String name() default "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.client;
|
package org.springframework.data.elasticsearch.client;
|
||||||
|
|
||||||
|
import static org.elasticsearch.node.NodeBuilder.*;
|
||||||
|
|
||||||
import org.elasticsearch.client.Client;
|
import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.client.node.NodeClient;
|
import org.elasticsearch.client.node.NodeClient;
|
||||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||||
@ -24,8 +26,6 @@ import org.springframework.beans.factory.DisposableBean;
|
|||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
||||||
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NodeClientFactoryBean
|
* NodeClientFactoryBean
|
||||||
*
|
*
|
||||||
|
@ -15,6 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.client;
|
package org.springframework.data.elasticsearch.client;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang.StringUtils.*;
|
||||||
|
import static org.elasticsearch.common.settings.ImmutableSettings.*;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.elasticsearch.client.transport.TransportClient;
|
import org.elasticsearch.client.transport.TransportClient;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
import org.elasticsearch.common.transport.InetSocketTransportAddress;
|
||||||
@ -25,11 +30,6 @@ import org.springframework.beans.factory.FactoryBean;
|
|||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import static org.apache.commons.lang.StringUtils.*;
|
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TransportClientFactoryBean
|
* TransportClientFactoryBean
|
||||||
*
|
*
|
||||||
@ -87,7 +87,7 @@ public class TransportClientFactoryBean implements FactoryBean<TransportClient>,
|
|||||||
protected void buildClient() throws Exception {
|
protected void buildClient() throws Exception {
|
||||||
client = new TransportClient(settings());
|
client = new TransportClient(settings());
|
||||||
Assert.hasText(clusterNodes, "[Assertion failed] clusterNodes settings missing.");
|
Assert.hasText(clusterNodes, "[Assertion failed] clusterNodes settings missing.");
|
||||||
for (String clusterNode : split(clusterNodes,COMMA)) {
|
for (String clusterNode : split(clusterNodes, COMMA)) {
|
||||||
String hostName = substringBefore(clusterNode, COLON);
|
String hostName = substringBefore(clusterNode, COLON);
|
||||||
String port = substringAfter(clusterNode, COLON);
|
String port = substringAfter(clusterNode, COLON);
|
||||||
Assert.hasText(hostName, "[Assertion failed] missing host name in 'clusterNodes'");
|
Assert.hasText(hostName, "[Assertion failed] missing host name in 'clusterNodes'");
|
||||||
|
@ -22,8 +22,6 @@ import org.springframework.beans.factory.xml.ParserContext;
|
|||||||
import org.springframework.data.elasticsearch.client.TransportClientFactoryBean;
|
import org.springframework.data.elasticsearch.client.TransportClientFactoryBean;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import static org.apache.commons.lang.StringUtils.split;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TransportClientBeanDefinitionParser
|
* TransportClientBeanDefinitionParser
|
||||||
*
|
*
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core;
|
package org.springframework.data.elasticsearch.core;
|
||||||
|
|
||||||
import org.springframework.data.elasticsearch.ElasticsearchException;
|
import static org.apache.commons.lang.StringUtils.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import static org.apache.commons.lang.StringUtils.isBlank;
|
import org.springframework.data.elasticsearch.ElasticsearchException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
|
@ -15,19 +15,21 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core;
|
package org.springframework.data.elasticsearch.core;
|
||||||
|
|
||||||
import org.elasticsearch.index.query.*;
|
import static org.elasticsearch.index.query.FilterBuilders.*;
|
||||||
import org.springframework.data.elasticsearch.core.geo.GeoBox;
|
import static org.springframework.data.elasticsearch.core.query.Criteria.*;
|
||||||
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
|
|
||||||
import org.springframework.data.elasticsearch.core.query.Criteria;
|
|
||||||
import org.springframework.util.Assert;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
|
||||||
import static org.elasticsearch.index.query.FilterBuilders.*;
|
import org.elasticsearch.index.query.FilterBuilder;
|
||||||
import static org.springframework.data.elasticsearch.core.query.Criteria.OperationKey;
|
import org.elasticsearch.index.query.GeoBoundingBoxFilterBuilder;
|
||||||
|
import org.elasticsearch.index.query.GeoDistanceFilterBuilder;
|
||||||
|
import org.springframework.data.elasticsearch.core.geo.GeoBox;
|
||||||
|
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
|
||||||
|
import org.springframework.data.elasticsearch.core.query.Criteria;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CriteriaFilterProcessor
|
* CriteriaFilterProcessor
|
||||||
@ -119,7 +121,6 @@ class CriteriaFilterProcessor {
|
|||||||
} else {
|
} else {
|
||||||
((GeoDistanceFilterBuilder) filter).geohash(loc).distance(dist);
|
((GeoDistanceFilterBuilder) filter).geohash(loc).distance(dist);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -145,7 +146,6 @@ class CriteriaFilterProcessor {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return filter;
|
return filter;
|
||||||
|
@ -15,19 +15,19 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core;
|
package org.springframework.data.elasticsearch.core;
|
||||||
|
|
||||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||||
import org.elasticsearch.index.query.BoostableQueryBuilder;
|
import static org.springframework.data.elasticsearch.core.query.Criteria.*;
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
|
||||||
import org.springframework.data.elasticsearch.core.query.Criteria;
|
|
||||||
import org.springframework.util.Assert;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
|
||||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||||
import static org.springframework.data.elasticsearch.core.query.Criteria.OperationKey;
|
import org.elasticsearch.index.query.BoostableQueryBuilder;
|
||||||
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
|
import org.springframework.data.elasticsearch.core.query.Criteria;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CriteriaQueryProcessor
|
* CriteriaQueryProcessor
|
||||||
@ -40,25 +40,24 @@ class CriteriaQueryProcessor {
|
|||||||
|
|
||||||
|
|
||||||
QueryBuilder createQueryFromCriteria(Criteria criteria) {
|
QueryBuilder createQueryFromCriteria(Criteria criteria) {
|
||||||
if(criteria == null)
|
if (criteria == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
List<QueryBuilder> shouldQueryBuilderList = new LinkedList<QueryBuilder>();
|
List<QueryBuilder> shouldQueryBuilderList = new LinkedList<QueryBuilder>();
|
||||||
List<QueryBuilder> mustNotQueryBuilderList = new LinkedList<QueryBuilder>();
|
List<QueryBuilder> mustNotQueryBuilderList = new LinkedList<QueryBuilder>();
|
||||||
List<QueryBuilder> mustQueryBuilderList = new LinkedList<QueryBuilder>();
|
List<QueryBuilder> mustQueryBuilderList = new LinkedList<QueryBuilder>();
|
||||||
|
|
||||||
|
|
||||||
ListIterator<Criteria> chainIterator = criteria.getCriteriaChain().listIterator();
|
ListIterator<Criteria> chainIterator = criteria.getCriteriaChain().listIterator();
|
||||||
while (chainIterator.hasNext()) {
|
while (chainIterator.hasNext()) {
|
||||||
Criteria chainedCriteria = chainIterator.next();
|
Criteria chainedCriteria = chainIterator.next();
|
||||||
QueryBuilder queryFragmentForCriteria = createQueryFragmentForCriteria(chainedCriteria);
|
QueryBuilder queryFragmentForCriteria = createQueryFragmentForCriteria(chainedCriteria);
|
||||||
|
|
||||||
if(queryFragmentForCriteria!=null) {
|
if (queryFragmentForCriteria != null) {
|
||||||
if(chainedCriteria.isOr()){
|
if (chainedCriteria.isOr()) {
|
||||||
shouldQueryBuilderList.add(queryFragmentForCriteria);
|
shouldQueryBuilderList.add(queryFragmentForCriteria);
|
||||||
}else if(chainedCriteria.isNegating()){
|
} else if (chainedCriteria.isNegating()) {
|
||||||
mustNotQueryBuilderList.add(queryFragmentForCriteria);
|
mustNotQueryBuilderList.add(queryFragmentForCriteria);
|
||||||
}else{
|
} else {
|
||||||
mustQueryBuilderList.add(queryFragmentForCriteria);
|
mustQueryBuilderList.add(queryFragmentForCriteria);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,17 +65,17 @@ class CriteriaQueryProcessor {
|
|||||||
|
|
||||||
BoolQueryBuilder query = null;
|
BoolQueryBuilder query = null;
|
||||||
|
|
||||||
if(!shouldQueryBuilderList.isEmpty() || !mustNotQueryBuilderList.isEmpty() || !mustQueryBuilderList.isEmpty()) {
|
if (!shouldQueryBuilderList.isEmpty() || !mustNotQueryBuilderList.isEmpty() || !mustQueryBuilderList.isEmpty()) {
|
||||||
|
|
||||||
query = boolQuery();
|
query = boolQuery();
|
||||||
|
|
||||||
for(QueryBuilder qb : shouldQueryBuilderList) {
|
for (QueryBuilder qb : shouldQueryBuilderList) {
|
||||||
query.should(qb);
|
query.should(qb);
|
||||||
}
|
}
|
||||||
for(QueryBuilder qb : mustNotQueryBuilderList) {
|
for (QueryBuilder qb : mustNotQueryBuilderList) {
|
||||||
query.mustNot(qb);
|
query.mustNot(qb);
|
||||||
}
|
}
|
||||||
for(QueryBuilder qb : mustQueryBuilderList) {
|
for (QueryBuilder qb : mustQueryBuilderList) {
|
||||||
query.must(qb);
|
query.must(qb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,24 +85,24 @@ class CriteriaQueryProcessor {
|
|||||||
|
|
||||||
|
|
||||||
private QueryBuilder createQueryFragmentForCriteria(Criteria chainedCriteria) {
|
private QueryBuilder createQueryFragmentForCriteria(Criteria chainedCriteria) {
|
||||||
if(chainedCriteria.getQueryCriteriaEntries().isEmpty())
|
if (chainedCriteria.getQueryCriteriaEntries().isEmpty())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
Iterator<Criteria.CriteriaEntry> it = chainedCriteria.getQueryCriteriaEntries().iterator();
|
Iterator<Criteria.CriteriaEntry> it = chainedCriteria.getQueryCriteriaEntries().iterator();
|
||||||
boolean singeEntryCriteria = (chainedCriteria.getQueryCriteriaEntries().size() == 1);
|
boolean singeEntryCriteria = (chainedCriteria.getQueryCriteriaEntries().size() == 1);
|
||||||
|
|
||||||
String fieldName = chainedCriteria.getField().getName();
|
String fieldName = chainedCriteria.getField().getName();
|
||||||
Assert.notNull(fieldName,"Unknown field");
|
Assert.notNull(fieldName, "Unknown field");
|
||||||
QueryBuilder query = null;
|
QueryBuilder query = null;
|
||||||
|
|
||||||
if(singeEntryCriteria){
|
if (singeEntryCriteria) {
|
||||||
Criteria.CriteriaEntry entry = it.next();
|
Criteria.CriteriaEntry entry = it.next();
|
||||||
query = processCriteriaEntry(entry.getKey(), entry.getValue(), fieldName);
|
query = processCriteriaEntry(entry.getKey(), entry.getValue(), fieldName);
|
||||||
}else{
|
} else {
|
||||||
query = boolQuery();
|
query = boolQuery();
|
||||||
while (it.hasNext()){
|
while (it.hasNext()) {
|
||||||
Criteria.CriteriaEntry entry = it.next();
|
Criteria.CriteriaEntry entry = it.next();
|
||||||
((BoolQueryBuilder)query).must(processCriteriaEntry(entry.getKey(), entry.getValue(), fieldName));
|
((BoolQueryBuilder) query).must(processCriteriaEntry(entry.getKey(), entry.getValue(), fieldName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +167,5 @@ class CriteriaQueryProcessor {
|
|||||||
if (query instanceof BoostableQueryBuilder) {
|
if (query instanceof BoostableQueryBuilder) {
|
||||||
((BoostableQueryBuilder) query).boost(boost);
|
((BoostableQueryBuilder) query).boost(boost);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core;
|
package org.springframework.data.elasticsearch.core;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DocumentMapper using jackson
|
* DocumentMapper using jackson
|
||||||
*
|
*
|
||||||
|
@ -16,6 +16,14 @@
|
|||||||
package org.springframework.data.elasticsearch.core;
|
package org.springframework.data.elasticsearch.core;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.elasticsearch.action.get.GetResponse;
|
import org.elasticsearch.action.get.GetResponse;
|
||||||
import org.elasticsearch.action.search.SearchResponse;
|
import org.elasticsearch.action.search.SearchResponse;
|
||||||
import org.elasticsearch.common.base.Strings;
|
import org.elasticsearch.common.base.Strings;
|
||||||
@ -34,14 +42,6 @@ import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersiste
|
|||||||
import org.springframework.data.mapping.PersistentProperty;
|
import org.springframework.data.mapping.PersistentProperty;
|
||||||
import org.springframework.data.mapping.context.MappingContext;
|
import org.springframework.data.mapping.context.MappingContext;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
*/
|
*/
|
||||||
@ -49,11 +49,11 @@ public class DefaultResultMapper extends AbstractResultMapper {
|
|||||||
|
|
||||||
private MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext;
|
private MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext;
|
||||||
|
|
||||||
public DefaultResultMapper(){
|
public DefaultResultMapper() {
|
||||||
super(new DefaultEntityMapper());
|
super(new DefaultEntityMapper());
|
||||||
}
|
}
|
||||||
|
|
||||||
public DefaultResultMapper(MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext){
|
public DefaultResultMapper(MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext) {
|
||||||
super(new DefaultEntityMapper());
|
super(new DefaultEntityMapper());
|
||||||
this.mappingContext = mappingContext;
|
this.mappingContext = mappingContext;
|
||||||
}
|
}
|
||||||
@ -122,21 +122,21 @@ public class DefaultResultMapper extends AbstractResultMapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T mapResult(GetResponse response, Class<T> clazz) {
|
public <T> T mapResult(GetResponse response, Class<T> clazz) {
|
||||||
T result = mapEntity(response.getSourceAsString(),clazz);
|
T result = mapEntity(response.getSourceAsString(), clazz);
|
||||||
if (result != null){
|
if (result != null) {
|
||||||
setPersistentEntityId(result, response.getId(), clazz);
|
setPersistentEntityId(result, response.getId(), clazz);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> void setPersistentEntityId(T result, String id, Class<T> clazz) {
|
private <T> void setPersistentEntityId(T result, String id, Class<T> clazz) {
|
||||||
if (mappingContext != null && clazz.isAnnotationPresent(Document.class)){
|
if (mappingContext != null && clazz.isAnnotationPresent(Document.class)) {
|
||||||
PersistentProperty<ElasticsearchPersistentProperty> idProperty = mappingContext.getPersistentEntity(clazz).getIdProperty();
|
PersistentProperty<ElasticsearchPersistentProperty> idProperty = mappingContext.getPersistentEntity(clazz).getIdProperty();
|
||||||
// Only deal with String because ES generated Ids are strings !
|
// Only deal with String because ES generated Ids are strings !
|
||||||
if (idProperty != null && idProperty.getType().isAssignableFrom(String.class)){
|
if (idProperty != null && idProperty.getType().isAssignableFrom(String.class)) {
|
||||||
Method setter = idProperty.getSetter();
|
Method setter = idProperty.getSetter();
|
||||||
if (setter != null){
|
if (setter != null) {
|
||||||
try{
|
try {
|
||||||
setter.invoke(result, id);
|
setter.invoke(result, id);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
|
@ -15,14 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core;
|
package org.springframework.data.elasticsearch.core;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.elasticsearch.action.update.UpdateResponse;
|
import org.elasticsearch.action.update.UpdateResponse;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
|
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
|
||||||
import org.springframework.data.elasticsearch.core.query.*;
|
import org.springframework.data.elasticsearch.core.query.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElasticsearchOperations
|
* ElasticsearchOperations
|
||||||
*
|
*
|
||||||
|
@ -15,6 +15,18 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core;
|
package org.springframework.data.elasticsearch.core;
|
||||||
|
|
||||||
|
import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
|
||||||
|
import static org.apache.commons.lang.StringUtils.*;
|
||||||
|
import static org.elasticsearch.action.search.SearchType.*;
|
||||||
|
import static org.elasticsearch.client.Requests.*;
|
||||||
|
import static org.elasticsearch.common.collect.Sets.*;
|
||||||
|
import static org.elasticsearch.index.VersionType.*;
|
||||||
|
import static org.springframework.data.elasticsearch.core.MappingBuilder.*;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest;
|
import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest;
|
||||||
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder;
|
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder;
|
||||||
@ -59,21 +71,6 @@ import org.springframework.data.elasticsearch.core.query.*;
|
|||||||
import org.springframework.data.mapping.PersistentProperty;
|
import org.springframework.data.mapping.PersistentProperty;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
|
|
||||||
import static org.apache.commons.lang.StringUtils.isBlank;
|
|
||||||
import static org.apache.commons.lang.StringUtils.isNotBlank;
|
|
||||||
import static org.elasticsearch.action.search.SearchType.DFS_QUERY_THEN_FETCH;
|
|
||||||
import static org.elasticsearch.action.search.SearchType.SCAN;
|
|
||||||
import static org.elasticsearch.client.Requests.indicesExistsRequest;
|
|
||||||
import static org.elasticsearch.client.Requests.refreshRequest;
|
|
||||||
import static org.elasticsearch.common.collect.Sets.newHashSet;
|
|
||||||
import static org.elasticsearch.index.VersionType.EXTERNAL;
|
|
||||||
import static org.springframework.data.elasticsearch.core.MappingBuilder.buildMapping;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElasticsearchTemplate
|
* ElasticsearchTemplate
|
||||||
*
|
*
|
||||||
@ -214,7 +211,7 @@ public class ElasticsearchTemplate implements ElasticsearchOperations {
|
|||||||
searchRequestBuilder.setQuery(QueryBuilders.matchAllQuery());
|
searchRequestBuilder.setQuery(QueryBuilders.matchAllQuery());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(criteriaQuery.getMinScore()>0){
|
if (criteriaQuery.getMinScore() > 0) {
|
||||||
searchRequestBuilder.setMinScore(criteriaQuery.getMinScore());
|
searchRequestBuilder.setMinScore(criteriaQuery.getMinScore());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +249,7 @@ public class ElasticsearchTemplate implements ElasticsearchOperations {
|
|||||||
public String index(IndexQuery query) {
|
public String index(IndexQuery query) {
|
||||||
String documentId = prepareIndex(query).execute().actionGet().getId();
|
String documentId = prepareIndex(query).execute().actionGet().getId();
|
||||||
// We should call this because we are not going through a mapper.
|
// We should call this because we are not going through a mapper.
|
||||||
if (query.getObject() != null){
|
if (query.getObject() != null) {
|
||||||
setPersistentEntityId(query.getObject(), documentId);
|
setPersistentEntityId(query.getObject(), documentId);
|
||||||
}
|
}
|
||||||
return documentId;
|
return documentId;
|
||||||
@ -534,7 +531,7 @@ public class ElasticsearchTemplate implements ElasticsearchOperations {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(query.getMinScore()>0){
|
if (query.getMinScore() > 0) {
|
||||||
searchRequestBuilder.setMinScore(query.getMinScore());
|
searchRequestBuilder.setMinScore(query.getMinScore());
|
||||||
}
|
}
|
||||||
return searchRequestBuilder;
|
return searchRequestBuilder;
|
||||||
@ -552,7 +549,7 @@ public class ElasticsearchTemplate implements ElasticsearchOperations {
|
|||||||
if (query.getObject() != null) {
|
if (query.getObject() != null) {
|
||||||
// If we have a query id and a document id, do not ask ES to generate one.
|
// If we have a query id and a document id, do not ask ES to generate one.
|
||||||
String entityId = getPersistentEntityId(query.getObject());
|
String entityId = getPersistentEntityId(query.getObject());
|
||||||
if (query.getId() != null && entityId != null){
|
if (query.getId() != null && entityId != null) {
|
||||||
indexRequestBuilder = client.prepareIndex(indexName, type, query.getId());
|
indexRequestBuilder = client.prepareIndex(indexName, type, query.getId());
|
||||||
} else {
|
} else {
|
||||||
indexRequestBuilder = client.prepareIndex(indexName, type);
|
indexRequestBuilder = client.prepareIndex(indexName, type);
|
||||||
@ -595,9 +592,9 @@ public class ElasticsearchTemplate implements ElasticsearchOperations {
|
|||||||
Assert.notNull(query.getIndexName(), "No index defined for Alias");
|
Assert.notNull(query.getIndexName(), "No index defined for Alias");
|
||||||
Assert.notNull(query.getAliasName(), "No alias defined");
|
Assert.notNull(query.getAliasName(), "No alias defined");
|
||||||
IndicesAliasesRequestBuilder indicesAliasesRequestBuilder = null;
|
IndicesAliasesRequestBuilder indicesAliasesRequestBuilder = null;
|
||||||
if(query.getFilterBuilder() != null) {
|
if (query.getFilterBuilder() != null) {
|
||||||
indicesAliasesRequestBuilder = client.admin().indices().prepareAliases().addAlias(query.getIndexName(), query.getAliasName(), query.getFilterBuilder());
|
indicesAliasesRequestBuilder = client.admin().indices().prepareAliases().addAlias(query.getIndexName(), query.getAliasName(), query.getFilterBuilder());
|
||||||
} else if(query.getFilter() != null) {
|
} else if (query.getFilter() != null) {
|
||||||
indicesAliasesRequestBuilder = client.admin().indices().prepareAliases().addAlias(query.getIndexName(), query.getAliasName(), query.getFilter());
|
indicesAliasesRequestBuilder = client.admin().indices().prepareAliases().addAlias(query.getIndexName(), query.getAliasName(), query.getFilter());
|
||||||
} else {
|
} else {
|
||||||
indicesAliasesRequestBuilder = client.admin().indices().prepareAliases().addAlias(query.getIndexName(), query.getAliasName());
|
indicesAliasesRequestBuilder = client.admin().indices().prepareAliases().addAlias(query.getIndexName(), query.getAliasName());
|
||||||
@ -629,18 +626,17 @@ public class ElasticsearchTemplate implements ElasticsearchOperations {
|
|||||||
return elasticsearchConverter.getMappingContext().getPersistentEntity(clazz);
|
return elasticsearchConverter.getMappingContext().getPersistentEntity(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPersistentEntityId(Object entity){
|
private String getPersistentEntityId(Object entity) {
|
||||||
PersistentProperty idProperty = getPersistentEntityFor(entity.getClass()).getIdProperty();
|
PersistentProperty idProperty = getPersistentEntityFor(entity.getClass()).getIdProperty();
|
||||||
if (idProperty != null){
|
if (idProperty != null) {
|
||||||
Method getter = idProperty.getGetter();
|
Method getter = idProperty.getGetter();
|
||||||
if (getter != null){
|
if (getter != null) {
|
||||||
try{
|
try {
|
||||||
Object id = getter.invoke(entity);
|
Object id = getter.invoke(entity);
|
||||||
if (id != null){
|
if (id != null) {
|
||||||
return String.valueOf(id);
|
return String.valueOf(id);
|
||||||
}
|
}
|
||||||
|
} catch (Throwable t) {
|
||||||
} catch (Throwable t){
|
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -648,13 +644,13 @@ public class ElasticsearchTemplate implements ElasticsearchOperations {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPersistentEntityId(Object entity, String id){
|
private void setPersistentEntityId(Object entity, String id) {
|
||||||
PersistentProperty idProperty = getPersistentEntityFor(entity.getClass()).getIdProperty();
|
PersistentProperty idProperty = getPersistentEntityFor(entity.getClass()).getIdProperty();
|
||||||
// Only deal with String because ES generated Ids are strings !
|
// Only deal with String because ES generated Ids are strings !
|
||||||
if (idProperty != null && idProperty.getType().isAssignableFrom(String.class)){
|
if (idProperty != null && idProperty.getType().isAssignableFrom(String.class)) {
|
||||||
Method setter = idProperty.getSetter();
|
Method setter = idProperty.getSetter();
|
||||||
if (setter != null){
|
if (setter != null) {
|
||||||
try{
|
try {
|
||||||
setter.invoke(entity, id);
|
setter.invoke(entity, id);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
@ -684,7 +680,6 @@ public class ElasticsearchTemplate implements ElasticsearchOperations {
|
|||||||
private static String[] toArray(List<String> values) {
|
private static String[] toArray(List<String> values) {
|
||||||
String[] valuesAsArray = new String[values.size()];
|
String[] valuesAsArray = new String[values.size()];
|
||||||
return values.toArray(valuesAsArray);
|
return values.toArray(valuesAsArray);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ResultsMapper getResultsMapper() {
|
protected ResultsMapper getResultsMapper() {
|
||||||
|
@ -15,13 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core;
|
package org.springframework.data.elasticsearch.core;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.elasticsearch.core.facet.FacetResult;
|
import org.springframework.data.elasticsearch.core.facet.FacetResult;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
@ -34,5 +33,4 @@ public interface FacetedPage<T> extends Page<T> {
|
|||||||
List<FacetResult> getFacets();
|
List<FacetResult> getFacets();
|
||||||
|
|
||||||
FacetResult getFacet(String name);
|
FacetResult getFacet(String name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,15 +15,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core;
|
package org.springframework.data.elasticsearch.core;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.springframework.data.domain.PageImpl;
|
import org.springframework.data.domain.PageImpl;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.elasticsearch.core.facet.FacetResult;
|
import org.springframework.data.elasticsearch.core.facet.FacetResult;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Container for query result and facet results
|
* Container for query result and facet results
|
||||||
*
|
*
|
||||||
|
@ -24,5 +24,4 @@ import org.elasticsearch.action.get.GetResponse;
|
|||||||
public interface GetResultMapper {
|
public interface GetResultMapper {
|
||||||
|
|
||||||
<T> T mapResult(GetResponse response, Class<T> clazz);
|
<T> T mapResult(GetResponse response, Class<T> clazz);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core;
|
package org.springframework.data.elasticsearch.core;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang.StringUtils.*;
|
||||||
|
import static org.elasticsearch.common.xcontent.XContentFactory.*;
|
||||||
|
import static org.springframework.util.StringUtils.*;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.springframework.core.GenericCollectionTypeResolver;
|
import org.springframework.core.GenericCollectionTypeResolver;
|
||||||
import org.springframework.data.annotation.Transient;
|
import org.springframework.data.annotation.Transient;
|
||||||
@ -25,15 +33,6 @@ import org.springframework.data.mapping.model.SimpleTypeHolder;
|
|||||||
import org.springframework.data.util.ClassTypeInformation;
|
import org.springframework.data.util.ClassTypeInformation;
|
||||||
import org.springframework.data.util.TypeInformation;
|
import org.springframework.data.util.TypeInformation;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static org.apache.commons.lang.StringUtils.EMPTY;
|
|
||||||
import static org.apache.commons.lang.StringUtils.isNotBlank;
|
|
||||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
|
||||||
import static org.springframework.util.StringUtils.hasText;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
@ -62,7 +61,7 @@ class MappingBuilder {
|
|||||||
XContentBuilder mapping = jsonBuilder().startObject().startObject(indexType);
|
XContentBuilder mapping = jsonBuilder().startObject().startObject(indexType);
|
||||||
// Parent
|
// Parent
|
||||||
if (hasText(parentType)) {
|
if (hasText(parentType)) {
|
||||||
mapping.startObject(FIELD_PARENT).field(FIELD_TYPE,parentType).endObject();
|
mapping.startObject(FIELD_PARENT).field(FIELD_TYPE, parentType).endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
@ -80,7 +79,7 @@ class MappingBuilder {
|
|||||||
|
|
||||||
if (!isRootObject && (isAnyPropertyAnnotatedAsField(fields) || nestedAnnotaion)) {
|
if (!isRootObject && (isAnyPropertyAnnotatedAsField(fields) || nestedAnnotaion)) {
|
||||||
String type = FieldType.Object.toString().toLowerCase();
|
String type = FieldType.Object.toString().toLowerCase();
|
||||||
if(nestedAnnotaion){
|
if (nestedAnnotaion) {
|
||||||
type = FieldType.Nested.toString().toLowerCase();
|
type = FieldType.Nested.toString().toLowerCase();
|
||||||
}
|
}
|
||||||
xContentBuilder.startObject(nestedObjectFieldName).field(FIELD_TYPE, type).startObject(FIELD_PROPERTIES);
|
xContentBuilder.startObject(nestedObjectFieldName).field(FIELD_TYPE, type).startObject(FIELD_PROPERTIES);
|
||||||
@ -96,12 +95,12 @@ class MappingBuilder {
|
|||||||
|
|
||||||
Field singleField = field.getAnnotation(Field.class);
|
Field singleField = field.getAnnotation(Field.class);
|
||||||
if (!isGeoField && isEntity(field) && !isAnnotated(field)) {
|
if (!isGeoField && isEntity(field) && !isAnnotated(field)) {
|
||||||
if(singleField == null){
|
if (singleField == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean nestedField = isNestedField(field);
|
boolean nestedField = isNestedField(field);
|
||||||
mapEntity(xContentBuilder, getFieldType(field), false, EMPTY, field.getName(), nestedField);
|
mapEntity(xContentBuilder, getFieldType(field), false, EMPTY, field.getName(), nestedField);
|
||||||
if(nestedField){
|
if (nestedField) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,11 +123,10 @@ class MappingBuilder {
|
|||||||
if (!isRootObject && isAnyPropertyAnnotatedAsField(fields)) {
|
if (!isRootObject && isAnyPropertyAnnotatedAsField(fields)) {
|
||||||
xContentBuilder.endObject().endObject();
|
xContentBuilder.endObject().endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isAnnotated(java.lang.reflect.Field field) {
|
private static boolean isAnnotated(java.lang.reflect.Field field) {
|
||||||
return field.getAnnotation(Field.class)==null && field.getAnnotation(MultiField.class)==null && field.getAnnotation(GeoPointField.class)==null;
|
return field.getAnnotation(Field.class) == null && field.getAnnotation(MultiField.class) == null && field.getAnnotation(GeoPointField.class) == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applyGeoPointFieldMapping(XContentBuilder xContentBuilder, java.lang.reflect.Field field) throws IOException {
|
private static void applyGeoPointFieldMapping(XContentBuilder xContentBuilder, java.lang.reflect.Field field) throws IOException {
|
||||||
@ -291,8 +289,8 @@ class MappingBuilder {
|
|||||||
|
|
||||||
private static boolean isInIgnoreFields(java.lang.reflect.Field field) {
|
private static boolean isInIgnoreFields(java.lang.reflect.Field field) {
|
||||||
Field fieldAnnotation = field.getAnnotation(Field.class);
|
Field fieldAnnotation = field.getAnnotation(Field.class);
|
||||||
if ( null != fieldAnnotation ) {
|
if (null != fieldAnnotation) {
|
||||||
String [] ignoreFields = fieldAnnotation.ignoreFields();
|
String[] ignoreFields = fieldAnnotation.ignoreFields();
|
||||||
return Arrays.asList(ignoreFields).contains(field.getName());
|
return Arrays.asList(ignoreFields).contains(field.getName());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -306,5 +304,4 @@ class MappingBuilder {
|
|||||||
private static boolean isGeoField(java.lang.reflect.Field field) {
|
private static boolean isGeoField(java.lang.reflect.Field field) {
|
||||||
return field.getType() == GeoPoint.class || field.getAnnotation(GeoPointField.class) != null;
|
return field.getType() == GeoPoint.class || field.getAnnotation(GeoPointField.class) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,5 +26,4 @@ package org.springframework.data.elasticsearch.core;
|
|||||||
public interface ResultsMapper extends SearchResultMapper, GetResultMapper {
|
public interface ResultsMapper extends SearchResultMapper, GetResultMapper {
|
||||||
|
|
||||||
EntityMapper getEntityMapper();
|
EntityMapper getEntityMapper();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,5 +24,4 @@ import org.springframework.data.domain.Pageable;
|
|||||||
public interface SearchResultMapper {
|
public interface SearchResultMapper {
|
||||||
|
|
||||||
<T> FacetedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable);
|
<T> FacetedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.convert;
|
package org.springframework.data.elasticsearch.core.convert;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import org.joda.time.DateTimeZone;
|
import org.joda.time.DateTimeZone;
|
||||||
import org.joda.time.LocalDateTime;
|
import org.joda.time.LocalDateTime;
|
||||||
import org.joda.time.ReadableInstant;
|
import org.joda.time.ReadableInstant;
|
||||||
@ -22,8 +24,6 @@ import org.joda.time.format.DateTimeFormatter;
|
|||||||
import org.joda.time.format.ISODateTimeFormat;
|
import org.joda.time.format.ISODateTimeFormat;
|
||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DateTimeConverters
|
* DateTimeConverters
|
||||||
*
|
*
|
||||||
@ -74,5 +74,4 @@ public final class DateTimeConverters {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -42,5 +42,4 @@ public interface ElasticsearchConverter {
|
|||||||
* @return never {@literal null}.
|
* @return never {@literal null}.
|
||||||
*/
|
*/
|
||||||
ConversionService getConversionService();
|
ConversionService getConversionService();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -62,5 +62,4 @@ public class MappingElasticsearchConverter implements ElasticsearchConverter, Ap
|
|||||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
this.applicationContext = applicationContext;
|
this.applicationContext = applicationContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public abstract class AbstractFacetRequest implements FacetRequest {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getName(){
|
protected String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,12 +23,12 @@ import org.springframework.util.Assert;
|
|||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
* @author Jonathan Yan
|
* @author Jonathan Yan
|
||||||
*/
|
*/
|
||||||
public class AbstactFacetResult implements FacetResult {
|
public class AbstractFacetResult implements FacetResult {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final FacetType type;
|
private final FacetType type;
|
||||||
|
|
||||||
protected AbstactFacetResult(String name, FacetType type) {
|
protected AbstractFacetResult(String name, FacetType type) {
|
||||||
Assert.hasText(name, "Facet name can't be null and should have a value");
|
Assert.hasText(name, "Facet name can't be null and should have a value");
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.type = type;
|
this.type = type;
|
@ -15,6 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.facet;
|
package org.springframework.data.elasticsearch.core.facet;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.elasticsearch.search.facet.Facet;
|
import org.elasticsearch.search.facet.Facet;
|
||||||
import org.elasticsearch.search.facet.histogram.HistogramFacet;
|
import org.elasticsearch.search.facet.histogram.HistogramFacet;
|
||||||
import org.elasticsearch.search.facet.range.RangeFacet;
|
import org.elasticsearch.search.facet.range.RangeFacet;
|
||||||
@ -22,9 +25,6 @@ import org.elasticsearch.search.facet.statistical.StatisticalFacet;
|
|||||||
import org.elasticsearch.search.facet.terms.TermsFacet;
|
import org.elasticsearch.search.facet.terms.TermsFacet;
|
||||||
import org.springframework.data.elasticsearch.core.facet.result.*;
|
import org.springframework.data.elasticsearch.core.facet.result.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
* @author Petar Tahchiev
|
* @author Petar Tahchiev
|
||||||
@ -78,5 +78,4 @@ public class DefaultFacetMapper {
|
|||||||
}
|
}
|
||||||
return new HistogramResult(facet.getName(), entries);
|
return new HistogramResult(facet.getName(), entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,5 +28,4 @@ public interface FacetRequest {
|
|||||||
FacetBuilder getFacet();
|
FacetBuilder getFacet();
|
||||||
|
|
||||||
boolean applyQueryFilter();
|
boolean applyQueryFilter();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,10 @@ package org.springframework.data.elasticsearch.core.facet;
|
|||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
* @author Jonathan Yan
|
* @author Jonathan Yan
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface FacetResult {
|
public interface FacetResult {
|
||||||
|
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
FacetType getType();
|
FacetType getType();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.facet.request;
|
package org.springframework.data.elasticsearch.core.facet.request;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.elasticsearch.search.facet.FacetBuilder;
|
import org.elasticsearch.search.facet.FacetBuilder;
|
||||||
import org.elasticsearch.search.facet.FacetBuilders;
|
import org.elasticsearch.search.facet.FacetBuilders;
|
||||||
@ -22,8 +24,6 @@ import org.elasticsearch.search.facet.histogram.HistogramFacetBuilder;
|
|||||||
import org.springframework.data.elasticsearch.core.facet.AbstractFacetRequest;
|
import org.springframework.data.elasticsearch.core.facet.AbstractFacetRequest;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.facet.request;
|
package org.springframework.data.elasticsearch.core.facet.request;
|
||||||
|
|
||||||
import org.springframework.data.elasticsearch.core.facet.FacetRequest;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.springframework.data.elasticsearch.core.facet.FacetRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
*/
|
*/
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.facet.request;
|
package org.springframework.data.elasticsearch.core.facet.request;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.elasticsearch.search.facet.FacetBuilder;
|
import org.elasticsearch.search.facet.FacetBuilder;
|
||||||
import org.elasticsearch.search.facet.FacetBuilders;
|
import org.elasticsearch.search.facet.FacetBuilders;
|
||||||
@ -22,9 +25,6 @@ import org.elasticsearch.search.facet.range.RangeFacetBuilder;
|
|||||||
import org.springframework.data.elasticsearch.core.facet.AbstractFacetRequest;
|
import org.springframework.data.elasticsearch.core.facet.AbstractFacetRequest;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Range facet for numeric fields
|
* Range facet for numeric fields
|
||||||
*
|
*
|
||||||
|
@ -15,15 +15,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.facet.result;
|
package org.springframework.data.elasticsearch.core.facet.result;
|
||||||
|
|
||||||
import org.springframework.data.elasticsearch.core.facet.AbstactFacetResult;
|
|
||||||
import org.springframework.data.elasticsearch.core.facet.FacetType;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.data.elasticsearch.core.facet.AbstractFacetResult;
|
||||||
|
import org.springframework.data.elasticsearch.core.facet.FacetType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
*/
|
*/
|
||||||
public class HistogramResult extends AbstactFacetResult {
|
public class HistogramResult extends AbstractFacetResult {
|
||||||
|
|
||||||
private List<IntervalUnit> terms;
|
private List<IntervalUnit> terms;
|
||||||
|
|
||||||
@ -35,5 +35,4 @@ public class HistogramResult extends AbstactFacetResult {
|
|||||||
public List<IntervalUnit> getIntervalUnit() {
|
public List<IntervalUnit> getIntervalUnit() {
|
||||||
return terms;
|
return terms;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.facet.result;
|
package org.springframework.data.elasticsearch.core.facet.result;
|
||||||
|
|
||||||
import org.springframework.data.elasticsearch.core.facet.AbstactFacetResult;
|
|
||||||
import org.springframework.data.elasticsearch.core.facet.FacetType;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.data.elasticsearch.core.facet.AbstractFacetResult;
|
||||||
|
import org.springframework.data.elasticsearch.core.facet.FacetType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic term facet result
|
* Basic term facet result
|
||||||
*
|
*
|
||||||
@ -28,7 +28,7 @@ import java.util.List;
|
|||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
* @author Jonathan Yan
|
* @author Jonathan Yan
|
||||||
*/
|
*/
|
||||||
public class RangeResult extends AbstactFacetResult {
|
public class RangeResult extends AbstractFacetResult {
|
||||||
|
|
||||||
private List<Range> ranges;
|
private List<Range> ranges;
|
||||||
|
|
||||||
@ -40,5 +40,4 @@ public class RangeResult extends AbstactFacetResult {
|
|||||||
public List<Range> getRanges() {
|
public List<Range> getRanges() {
|
||||||
return ranges;
|
return ranges;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.facet.result;
|
package org.springframework.data.elasticsearch.core.facet.result;
|
||||||
|
|
||||||
import org.springframework.data.elasticsearch.core.facet.AbstactFacetResult;
|
import org.springframework.data.elasticsearch.core.facet.AbstractFacetResult;
|
||||||
import org.springframework.data.elasticsearch.core.facet.FacetType;
|
import org.springframework.data.elasticsearch.core.facet.FacetType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Petar Tahchiev
|
* @author Petar Tahchiev
|
||||||
*/
|
*/
|
||||||
public class StatisticalResult extends AbstactFacetResult {
|
public class StatisticalResult extends AbstractFacetResult {
|
||||||
|
|
||||||
private long count;
|
private long count;
|
||||||
|
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.facet.result;
|
package org.springframework.data.elasticsearch.core.facet.result;
|
||||||
|
|
||||||
import org.springframework.data.elasticsearch.core.facet.AbstactFacetResult;
|
|
||||||
import org.springframework.data.elasticsearch.core.facet.FacetType;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.data.elasticsearch.core.facet.AbstractFacetResult;
|
||||||
|
import org.springframework.data.elasticsearch.core.facet.FacetType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic term facet result
|
* Basic term facet result
|
||||||
*
|
*
|
||||||
@ -28,7 +28,7 @@ import java.util.List;
|
|||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
* @author Jonathan Yan
|
* @author Jonathan Yan
|
||||||
*/
|
*/
|
||||||
public class TermResult extends AbstactFacetResult {
|
public class TermResult extends AbstractFacetResult {
|
||||||
|
|
||||||
private List<Term> terms;
|
private List<Term> terms;
|
||||||
|
|
||||||
@ -40,5 +40,4 @@ public class TermResult extends AbstactFacetResult {
|
|||||||
public List<Term> getTerms() {
|
public List<Term> getTerms() {
|
||||||
return terms;
|
return terms;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,5 +37,4 @@ public class GeoBox {
|
|||||||
public GeoPoint getBottomRight() {
|
public GeoPoint getBottomRight() {
|
||||||
return bottomRight;
|
return bottomRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -41,5 +41,4 @@ public class GeoPoint {
|
|||||||
public double getLon() {
|
public double getLon() {
|
||||||
return lon;
|
return lon;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -37,5 +37,4 @@ public interface ElasticsearchPersistentProperty extends PersistentProperty<Elas
|
|||||||
return source.getFieldName();
|
return source.getFieldName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.mapping;
|
package org.springframework.data.elasticsearch.core.mapping;
|
||||||
|
|
||||||
|
import java.beans.PropertyDescriptor;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import org.springframework.data.mapping.context.AbstractMappingContext;
|
import org.springframework.data.mapping.context.AbstractMappingContext;
|
||||||
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||||
import org.springframework.data.util.TypeInformation;
|
import org.springframework.data.util.TypeInformation;
|
||||||
|
|
||||||
import java.beans.PropertyDescriptor;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SimpleElasticsearchMappingContext
|
* SimpleElasticsearchMappingContext
|
||||||
*
|
*
|
||||||
@ -42,5 +42,4 @@ public class SimpleElasticsearchMappingContext extends
|
|||||||
SimpleElasticsearchPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) {
|
SimpleElasticsearchPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) {
|
||||||
return new SimpleElasticsearchPersistentProperty(field, descriptor, owner, simpleTypeHolder);
|
return new SimpleElasticsearchPersistentProperty(field, descriptor, owner, simpleTypeHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.mapping;
|
package org.springframework.data.elasticsearch.core.mapping;
|
||||||
|
|
||||||
|
import static org.springframework.util.StringUtils.*;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.context.ApplicationContextAware;
|
||||||
@ -27,15 +31,10 @@ import org.springframework.data.util.TypeInformation;
|
|||||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import static org.springframework.util.StringUtils.hasText;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Elasticsearch specific {@link org.springframework.data.mapping.PersistentEntity} implementation holding
|
* Elasticsearch specific {@link org.springframework.data.mapping.PersistentEntity} implementation holding
|
||||||
*
|
*
|
||||||
* @param <T>
|
* @param <T>
|
||||||
*
|
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
|
@ -15,16 +15,16 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.mapping;
|
package org.springframework.data.elasticsearch.core.mapping;
|
||||||
|
|
||||||
import org.springframework.data.mapping.Association;
|
|
||||||
import org.springframework.data.mapping.PersistentEntity;
|
|
||||||
import org.springframework.data.mapping.model.AnnotationBasedPersistentProperty;
|
|
||||||
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
|
||||||
|
|
||||||
import java.beans.PropertyDescriptor;
|
import java.beans.PropertyDescriptor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.springframework.data.mapping.Association;
|
||||||
|
import org.springframework.data.mapping.PersistentEntity;
|
||||||
|
import org.springframework.data.mapping.model.AnnotationBasedPersistentProperty;
|
||||||
|
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Elasticsearch specific {@link org.springframework.data.mapping.PersistentProperty} implementation processing
|
* Elasticsearch specific {@link org.springframework.data.mapping.PersistentProperty} implementation processing
|
||||||
*
|
*
|
||||||
@ -62,5 +62,4 @@ public class SimpleElasticsearchPersistentProperty extends
|
|||||||
protected Association<ElasticsearchPersistentProperty> createAssociation() {
|
protected Association<ElasticsearchPersistentProperty> createAssociation() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,14 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
import org.springframework.data.domain.Pageable;
|
import static org.apache.commons.collections.CollectionUtils.*;
|
||||||
import org.springframework.data.domain.Sort;
|
|
||||||
import org.springframework.util.Assert;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.apache.commons.collections.CollectionUtils.addAll;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractQuery
|
* AbstractQuery
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.elasticsearch.index.query.FilterBuilder;
|
import org.elasticsearch.index.query.FilterBuilder;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
public class AliasBuilder {
|
public class AliasBuilder {
|
||||||
@ -29,27 +29,27 @@ public class AliasBuilder {
|
|||||||
private FilterBuilder filterBuilder;
|
private FilterBuilder filterBuilder;
|
||||||
private Map<String, Object> filter;
|
private Map<String, Object> filter;
|
||||||
|
|
||||||
public AliasBuilder withIndexName(String indexName){
|
public AliasBuilder withIndexName(String indexName) {
|
||||||
this.indexName = indexName;
|
this.indexName = indexName;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AliasBuilder withAliasName(String aliasName){
|
public AliasBuilder withAliasName(String aliasName) {
|
||||||
this.aliasName = aliasName;
|
this.aliasName = aliasName;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AliasBuilder withFilterBuilder(FilterBuilder filterBuilder){
|
public AliasBuilder withFilterBuilder(FilterBuilder filterBuilder) {
|
||||||
this.filterBuilder = filterBuilder;
|
this.filterBuilder = filterBuilder;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AliasBuilder withFilter(Map<String, Object> filter){
|
public AliasBuilder withFilter(Map<String, Object> filter) {
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AliasQuery build(){
|
public AliasQuery build() {
|
||||||
AliasQuery aliasQuery = new AliasQuery();
|
AliasQuery aliasQuery = new AliasQuery();
|
||||||
aliasQuery.setIndexName(indexName);
|
aliasQuery.setIndexName(indexName);
|
||||||
aliasQuery.setAliasName(aliasName);
|
aliasQuery.setAliasName(aliasName);
|
||||||
|
@ -14,8 +14,11 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
import org.elasticsearch.index.query.FilterBuilder;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.elasticsearch.index.query.FilterBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AliasQuery is useful for creating new alias or deleting existing ones
|
* AliasQuery is useful for creating new alias or deleting existing ones
|
||||||
*
|
*
|
||||||
|
@ -15,13 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||||
@ -508,7 +502,6 @@ public class Criteria {
|
|||||||
public String getConjunctionOperator() {
|
public String getConjunctionOperator() {
|
||||||
return OR_OPERATOR;
|
return OR_OPERATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum OperationKey {
|
public enum OperationKey {
|
||||||
@ -532,7 +525,5 @@ public class Criteria {
|
|||||||
public Object getValue() {
|
public Object getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -77,5 +77,4 @@ public class CriteriaQuery extends AbstractQuery {
|
|||||||
public Criteria getCriteria() {
|
public Criteria getCriteria() {
|
||||||
return this.criteria;
|
return this.criteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,5 +29,4 @@ public interface Field {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
import org.springframework.data.domain.Pageable;
|
import static org.apache.commons.collections.CollectionUtils.*;
|
||||||
|
import static org.springframework.data.elasticsearch.core.query.AbstractQuery.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.apache.commons.collections.CollectionUtils.addAll;
|
import org.springframework.data.domain.Pageable;
|
||||||
import static org.springframework.data.elasticsearch.core.query.AbstractQuery.DEFAULT_PAGE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MoreLikeThisQuery
|
* MoreLikeThisQuery
|
||||||
|
@ -15,15 +15,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.elasticsearch.index.query.FilterBuilder;
|
import org.elasticsearch.index.query.FilterBuilder;
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
import org.elasticsearch.search.highlight.HighlightBuilder;
|
import org.elasticsearch.search.highlight.HighlightBuilder;
|
||||||
import org.elasticsearch.search.sort.SortBuilder;
|
import org.elasticsearch.search.sort.SortBuilder;
|
||||||
import org.springframework.data.elasticsearch.core.facet.FacetRequest;
|
import org.springframework.data.elasticsearch.core.facet.FacetRequest;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NativeSearchQuery
|
* NativeSearchQuery
|
||||||
*
|
*
|
||||||
@ -79,14 +79,14 @@ public class NativeSearchQuery extends AbstractQuery implements SearchQuery {
|
|||||||
return highlightFields;
|
return highlightFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFacet(FacetRequest facetRequest){
|
public void addFacet(FacetRequest facetRequest) {
|
||||||
if(facets==null){
|
if (facets == null) {
|
||||||
facets = new ArrayList<FacetRequest>();
|
facets = new ArrayList<FacetRequest>();
|
||||||
}
|
}
|
||||||
facets.add(facetRequest);
|
facets.add(facetRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFacets(List<FacetRequest> facets){
|
public void setFacets(List<FacetRequest> facets) {
|
||||||
this.facets = facets;
|
this.facets = facets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.elasticsearch.index.query.FilterBuilder;
|
import org.elasticsearch.index.query.FilterBuilder;
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
@ -23,9 +26,6 @@ import org.elasticsearch.search.sort.SortBuilder;
|
|||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.elasticsearch.core.facet.FacetRequest;
|
import org.springframework.data.elasticsearch.core.facet.FacetRequest;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NativeSearchQuery
|
* NativeSearchQuery
|
||||||
*
|
*
|
||||||
@ -67,7 +67,7 @@ public class NativeSearchQueryBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NativeSearchQueryBuilder withHighlightFields(HighlightBuilder.Field... highlightFields){
|
public NativeSearchQueryBuilder withHighlightFields(HighlightBuilder.Field... highlightFields) {
|
||||||
this.highlightFields = highlightFields;
|
this.highlightFields = highlightFields;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ public class NativeSearchQueryBuilder {
|
|||||||
nativeSearchQuery.setFacets(facetRequests);
|
nativeSearchQuery.setFacets(facetRequests);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(minScore>0){
|
if (minScore > 0) {
|
||||||
nativeSearchQuery.setMinScore(minScore);
|
nativeSearchQuery.setMinScore(minScore);
|
||||||
}
|
}
|
||||||
return nativeSearchQuery;
|
return nativeSearchQuery;
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query
|
* Query
|
||||||
*
|
*
|
||||||
@ -111,6 +111,7 @@ public interface Query {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get minimum score
|
* Get minimum score
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
float getMinScore();
|
float getMinScore();
|
||||||
|
@ -15,14 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core.query;
|
package org.springframework.data.elasticsearch.core.query;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.elasticsearch.index.query.FilterBuilder;
|
import org.elasticsearch.index.query.FilterBuilder;
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
import org.elasticsearch.search.highlight.HighlightBuilder;
|
import org.elasticsearch.search.highlight.HighlightBuilder;
|
||||||
import org.elasticsearch.search.sort.SortBuilder;
|
import org.elasticsearch.search.sort.SortBuilder;
|
||||||
import org.springframework.data.elasticsearch.core.facet.FacetRequest;
|
import org.springframework.data.elasticsearch.core.facet.FacetRequest;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NativeSearchQuery
|
* NativeSearchQuery
|
||||||
*
|
*
|
||||||
@ -31,6 +31,7 @@ import java.util.List;
|
|||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
*/
|
*/
|
||||||
public interface SearchQuery extends Query {
|
public interface SearchQuery extends Query {
|
||||||
|
|
||||||
QueryBuilder getQuery();
|
QueryBuilder getQuery();
|
||||||
|
|
||||||
FilterBuilder getFilter();
|
FilterBuilder getFilter();
|
||||||
|
@ -38,5 +38,4 @@ public class SimpleField implements Field {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -46,5 +46,4 @@ public class StringQuery extends AbstractQuery {
|
|||||||
public String getSource() {
|
public String getSource() {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,37 +30,37 @@ public class UpdateQueryBuilder {
|
|||||||
private Class clazz;
|
private Class clazz;
|
||||||
private boolean doUpsert;
|
private boolean doUpsert;
|
||||||
|
|
||||||
public UpdateQueryBuilder withId(String id){
|
public UpdateQueryBuilder withId(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UpdateQueryBuilder withIndexRequest(IndexRequest indexRequest){
|
public UpdateQueryBuilder withIndexRequest(IndexRequest indexRequest) {
|
||||||
this.indexRequest = indexRequest;
|
this.indexRequest = indexRequest;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UpdateQueryBuilder withIndexName(String indexName){
|
public UpdateQueryBuilder withIndexName(String indexName) {
|
||||||
this.indexName = indexName;
|
this.indexName = indexName;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UpdateQueryBuilder withType(String type){
|
public UpdateQueryBuilder withType(String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UpdateQueryBuilder withClass(Class clazz){
|
public UpdateQueryBuilder withClass(Class clazz) {
|
||||||
this.clazz = clazz;
|
this.clazz = clazz;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UpdateQueryBuilder withDoUpsert(boolean doUpsert){
|
public UpdateQueryBuilder withDoUpsert(boolean doUpsert) {
|
||||||
this.doUpsert = doUpsert;
|
this.doUpsert = doUpsert;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UpdateQuery build(){
|
public UpdateQuery build() {
|
||||||
UpdateQuery updateQuery = new UpdateQuery();
|
UpdateQuery updateQuery = new UpdateQuery();
|
||||||
updateQuery.setId(id);
|
updateQuery.setId(id);
|
||||||
updateQuery.setIndexName(indexName);
|
updateQuery.setIndexName(indexName);
|
||||||
|
@ -23,7 +23,6 @@ import org.springframework.data.repository.PagingAndSortingRepository;
|
|||||||
/**
|
/**
|
||||||
* @param <T>
|
* @param <T>
|
||||||
* @param <ID>
|
* @param <ID>
|
||||||
*
|
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.repository;
|
package org.springframework.data.elasticsearch.repository;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
@ -22,12 +24,9 @@ import org.springframework.data.elasticsearch.core.FacetedPage;
|
|||||||
import org.springframework.data.elasticsearch.core.query.SearchQuery;
|
import org.springframework.data.elasticsearch.core.query.SearchQuery;
|
||||||
import org.springframework.data.repository.NoRepositoryBean;
|
import org.springframework.data.repository.NoRepositoryBean;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param <T>
|
* @param <T>
|
||||||
* @param <ID>
|
* @param <ID>
|
||||||
*
|
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
@ -42,5 +41,5 @@ public interface ElasticsearchRepository<T, ID extends Serializable> extends Ela
|
|||||||
|
|
||||||
FacetedPage<T> search(SearchQuery searchQuery);
|
FacetedPage<T> search(SearchQuery searchQuery);
|
||||||
|
|
||||||
Page<T> searchSimilar(T entity,String[] fields, Pageable pageable);
|
Page<T> searchSimilar(T entity, String[] fields, Pageable pageable);
|
||||||
}
|
}
|
||||||
|
@ -15,17 +15,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.repository.cdi;
|
package org.springframework.data.elasticsearch.repository.cdi;
|
||||||
|
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
|
||||||
import org.springframework.data.elasticsearch.repository.support.ElasticsearchRepositoryFactory;
|
|
||||||
import org.springframework.data.repository.cdi.CdiRepositoryBean;
|
|
||||||
import org.springframework.util.Assert;
|
|
||||||
|
|
||||||
import javax.enterprise.context.spi.CreationalContext;
|
import javax.enterprise.context.spi.CreationalContext;
|
||||||
import javax.enterprise.inject.spi.Bean;
|
import javax.enterprise.inject.spi.Bean;
|
||||||
import javax.enterprise.inject.spi.BeanManager;
|
import javax.enterprise.inject.spi.BeanManager;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||||
|
import org.springframework.data.elasticsearch.repository.support.ElasticsearchRepositoryFactory;
|
||||||
|
import org.springframework.data.repository.cdi.CdiRepositoryBean;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses CdiRepositoryBean to create ElasticsearchRepository instances.
|
* Uses CdiRepositoryBean to create ElasticsearchRepository instances.
|
||||||
*
|
*
|
||||||
@ -55,5 +55,4 @@ public class ElasticsearchRepositoryBean<T> extends CdiRepositoryBean<T> {
|
|||||||
public Class<? extends Annotation> getScope() {
|
public Class<? extends Annotation> getScope() {
|
||||||
return elasticsearchOperationsBean.getScope();
|
return elasticsearchOperationsBean.getScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.repository.cdi;
|
package org.springframework.data.elasticsearch.repository.cdi;
|
||||||
|
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
|
||||||
import org.springframework.data.repository.cdi.CdiRepositoryBean;
|
|
||||||
import org.springframework.data.repository.cdi.CdiRepositoryExtensionSupport;
|
|
||||||
|
|
||||||
import javax.enterprise.event.Observes;
|
import javax.enterprise.event.Observes;
|
||||||
import javax.enterprise.inject.UnsatisfiedResolutionException;
|
import javax.enterprise.inject.UnsatisfiedResolutionException;
|
||||||
import javax.enterprise.inject.spi.AfterBeanDiscovery;
|
import javax.enterprise.inject.spi.AfterBeanDiscovery;
|
||||||
@ -32,6 +28,10 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||||
|
import org.springframework.data.repository.cdi.CdiRepositoryBean;
|
||||||
|
import org.springframework.data.repository.cdi.CdiRepositoryExtensionSupport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElasticsearchRepositoryExtension
|
* ElasticsearchRepositoryExtension
|
||||||
*
|
*
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.repository.config;
|
package org.springframework.data.elasticsearch.repository.config;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
|
||||||
import org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport;
|
import org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport;
|
||||||
import org.springframework.data.repository.config.RepositoryConfigurationExtension;
|
import org.springframework.data.repository.config.RepositoryConfigurationExtension;
|
||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link org.springframework.context.annotation.ImportBeanDefinitionRegistrar} implementation to trigger configuration
|
* {@link org.springframework.context.annotation.ImportBeanDefinitionRegistrar} implementation to trigger configuration
|
||||||
* of the {@link EnableElasticsearchRepositories} annotation.
|
* of the {@link EnableElasticsearchRepositories} annotation.
|
||||||
|
@ -15,14 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.repository.config;
|
package org.springframework.data.elasticsearch.repository.config;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
|
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
|
||||||
import org.springframework.data.elasticsearch.repository.support.ElasticsearchRepositoryFactoryBean;
|
import org.springframework.data.elasticsearch.repository.support.ElasticsearchRepositoryFactoryBean;
|
||||||
import org.springframework.data.repository.query.QueryLookupStrategy.Key;
|
import org.springframework.data.repository.query.QueryLookupStrategy.Key;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation to enable Elasticsearch repositories. Will scan the package of the annotated configuration class for
|
* Annotation to enable Elasticsearch repositories. Will scan the package of the annotated configuration class for
|
||||||
* Spring Data repositories by default.
|
* Spring Data repositories by default.
|
||||||
|
@ -41,5 +41,4 @@ public abstract class AbstractElasticsearchRepositoryQuery implements Repository
|
|||||||
public QueryMethod getQueryMethod() {
|
public QueryMethod getQueryMethod() {
|
||||||
return queryMethod;
|
return queryMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.repository.query;
|
package org.springframework.data.elasticsearch.repository.query;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.springframework.core.annotation.AnnotationUtils;
|
import org.springframework.core.annotation.AnnotationUtils;
|
||||||
import org.springframework.data.elasticsearch.annotations.Query;
|
import org.springframework.data.elasticsearch.annotations.Query;
|
||||||
import org.springframework.data.elasticsearch.repository.support.ElasticsearchEntityInformation;
|
import org.springframework.data.elasticsearch.repository.support.ElasticsearchEntityInformation;
|
||||||
@ -23,8 +25,6 @@ import org.springframework.data.repository.core.RepositoryMetadata;
|
|||||||
import org.springframework.data.repository.query.QueryMethod;
|
import org.springframework.data.repository.query.QueryMethod;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElasticsearchQueryMethod
|
* ElasticsearchQueryMethod
|
||||||
*
|
*
|
||||||
@ -56,5 +56,4 @@ public class ElasticsearchQueryMethod extends QueryMethod {
|
|||||||
private Query getQueryAnnotation() {
|
private Query getQueryAnnotation() {
|
||||||
return this.method.getAnnotation(Query.class);
|
return this.method.getAnnotation(Query.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.repository.query;
|
package org.springframework.data.elasticsearch.repository.query;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.springframework.core.convert.support.GenericConversionService;
|
import org.springframework.core.convert.support.GenericConversionService;
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||||
import org.springframework.data.elasticsearch.core.convert.DateTimeConverters;
|
import org.springframework.data.elasticsearch.core.convert.DateTimeConverters;
|
||||||
@ -22,9 +25,6 @@ import org.springframework.data.elasticsearch.core.query.StringQuery;
|
|||||||
import org.springframework.data.repository.query.ParametersParameterAccessor;
|
import org.springframework.data.repository.query.ParametersParameterAccessor;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElasticsearchStringQuery
|
* ElasticsearchStringQuery
|
||||||
*
|
*
|
||||||
@ -48,7 +48,6 @@ public class ElasticsearchStringQuery extends AbstractElasticsearchRepositoryQue
|
|||||||
if (!conversionService.canConvert(org.joda.time.LocalDateTime.class, String.class)) {
|
if (!conversionService.canConvert(org.joda.time.LocalDateTime.class, String.class)) {
|
||||||
conversionService.addConverter(DateTimeConverters.JodaLocalDateTimeConverter.INSTANCE);
|
conversionService.addConverter(DateTimeConverters.JodaLocalDateTimeConverter.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ElasticsearchStringQuery(ElasticsearchQueryMethod queryMethod,
|
public ElasticsearchStringQuery(ElasticsearchQueryMethod queryMethod,
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.repository.query.parser;
|
package org.springframework.data.elasticsearch.repository.query.parser;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
|
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
|
||||||
@ -27,9 +30,6 @@ import org.springframework.data.repository.query.parser.AbstractQueryCreator;
|
|||||||
import org.springframework.data.repository.query.parser.Part;
|
import org.springframework.data.repository.query.parser.Part;
|
||||||
import org.springframework.data.repository.query.parser.PartTree;
|
import org.springframework.data.repository.query.parser.PartTree;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElasticsearchQueryCreator
|
* ElasticsearchQueryCreator
|
||||||
*
|
*
|
||||||
@ -131,7 +131,6 @@ public class ElasticsearchQueryCreator extends AbstractQueryCreator<CriteriaQuer
|
|||||||
} else if (o.getClass().isArray()) {
|
} else if (o.getClass().isArray()) {
|
||||||
return (Object[]) o;
|
return (Object[]) o;
|
||||||
}
|
}
|
||||||
return new Object[] { o };
|
return new Object[]{o};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,14 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.repository.support;
|
package org.springframework.data.elasticsearch.repository.support;
|
||||||
|
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
|
||||||
import org.springframework.data.domain.*;
|
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
|
||||||
import org.springframework.data.elasticsearch.core.FacetedPage;
|
|
||||||
import org.springframework.data.elasticsearch.core.query.*;
|
|
||||||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
|
||||||
import org.springframework.util.Assert;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
@ -32,14 +25,19 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.elasticsearch.index.query.QueryBuilders.inQuery;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||||
|
import org.springframework.data.domain.*;
|
||||||
|
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||||
|
import org.springframework.data.elasticsearch.core.FacetedPage;
|
||||||
|
import org.springframework.data.elasticsearch.core.query.*;
|
||||||
|
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Elasticsearch specific repository implementation. Likely to be used as target within
|
* Elasticsearch specific repository implementation. Likely to be used as target within
|
||||||
* {@link ElasticsearchRepositoryFactory}
|
* {@link ElasticsearchRepositoryFactory}
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
* @author Ryan Henszey
|
* @author Ryan Henszey
|
||||||
@ -88,7 +86,7 @@ public abstract class AbstractElasticsearchRepository<T, ID extends Serializable
|
|||||||
public Iterable<T> findAll() {
|
public Iterable<T> findAll() {
|
||||||
int itemCount = (int) this.count();
|
int itemCount = (int) this.count();
|
||||||
if (itemCount == 0) {
|
if (itemCount == 0) {
|
||||||
return new PageImpl<T>(Collections.<T> emptyList());
|
return new PageImpl<T>(Collections.<T>emptyList());
|
||||||
}
|
}
|
||||||
return this.findAll(new PageRequest(0, Math.max(1, itemCount)));
|
return this.findAll(new PageRequest(0, Math.max(1, itemCount)));
|
||||||
}
|
}
|
||||||
@ -103,7 +101,7 @@ public abstract class AbstractElasticsearchRepository<T, ID extends Serializable
|
|||||||
public Iterable<T> findAll(Sort sort) {
|
public Iterable<T> findAll(Sort sort) {
|
||||||
int itemCount = (int) this.count();
|
int itemCount = (int) this.count();
|
||||||
if (itemCount == 0) {
|
if (itemCount == 0) {
|
||||||
return new PageImpl<T>(Collections.<T> emptyList());
|
return new PageImpl<T>(Collections.<T>emptyList());
|
||||||
}
|
}
|
||||||
SearchQuery query = new NativeSearchQueryBuilder().withQuery(matchAllQuery())
|
SearchQuery query = new NativeSearchQueryBuilder().withQuery(matchAllQuery())
|
||||||
.withPageable(new PageRequest(0, itemCount, sort)).build();
|
.withPageable(new PageRequest(0, itemCount, sort)).build();
|
||||||
@ -173,7 +171,7 @@ public abstract class AbstractElasticsearchRepository<T, ID extends Serializable
|
|||||||
SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(query).build();
|
SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(query).build();
|
||||||
int count = (int) elasticsearchOperations.count(searchQuery, getEntityClass());
|
int count = (int) elasticsearchOperations.count(searchQuery, getEntityClass());
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
return new PageImpl<T>(Collections.<T> emptyList());
|
return new PageImpl<T>(Collections.<T>emptyList());
|
||||||
}
|
}
|
||||||
searchQuery.setPageable(new PageRequest(0, count));
|
searchQuery.setPageable(new PageRequest(0, count));
|
||||||
return elasticsearchOperations.queryForPage(searchQuery, getEntityClass());
|
return elasticsearchOperations.queryForPage(searchQuery, getEntityClass());
|
||||||
@ -197,7 +195,7 @@ public abstract class AbstractElasticsearchRepository<T, ID extends Serializable
|
|||||||
MoreLikeThisQuery query = new MoreLikeThisQuery();
|
MoreLikeThisQuery query = new MoreLikeThisQuery();
|
||||||
query.setId(stringIdRepresentation(extractIdFromBean(entity)));
|
query.setId(stringIdRepresentation(extractIdFromBean(entity)));
|
||||||
query.setPageable(pageable);
|
query.setPageable(pageable);
|
||||||
if(fields != null){
|
if (fields != null) {
|
||||||
query.addFields(fields);
|
query.addFields(fields);
|
||||||
}
|
}
|
||||||
return elasticsearchOperations.moreLikeThis(query, getEntityClass());
|
return elasticsearchOperations.moreLikeThis(query, getEntityClass());
|
||||||
|
@ -15,14 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.repository.support;
|
package org.springframework.data.elasticsearch.repository.support;
|
||||||
|
|
||||||
import org.springframework.data.repository.core.EntityInformation;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import org.springframework.data.repository.core.EntityInformation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param <T>
|
* @param <T>
|
||||||
* @param <ID>
|
* @param <ID>
|
||||||
*
|
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
|
@ -26,5 +26,4 @@ import java.io.Serializable;
|
|||||||
public interface ElasticsearchEntityInformationCreator {
|
public interface ElasticsearchEntityInformationCreator {
|
||||||
|
|
||||||
<T, ID extends Serializable> ElasticsearchEntityInformation<T, ID> getEntityInformation(Class<T> domainClass);
|
<T, ID extends Serializable> ElasticsearchEntityInformation<T, ID> getEntityInformation(Class<T> domainClass);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.repository.support;
|
package org.springframework.data.elasticsearch.repository.support;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity;
|
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity;
|
||||||
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
|
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
|
||||||
import org.springframework.data.mapping.context.MappingContext;
|
import org.springframework.data.mapping.context.MappingContext;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ElasticsearchEntityInformationCreatorImpl
|
* ElasticsearchEntityInformationCreatorImpl
|
||||||
*
|
*
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.repository.support;
|
package org.springframework.data.elasticsearch.repository.support;
|
||||||
|
|
||||||
import static org.springframework.data.querydsl.QueryDslUtils.QUERY_DSL_PRESENT;
|
import static org.springframework.data.querydsl.QueryDslUtils.*;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -58,7 +58,7 @@ public class ElasticsearchRepositoryFactory extends RepositoryFactorySupport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
protected Object getTargetRepository(RepositoryMetadata metadata) {
|
protected Object getTargetRepository(RepositoryMetadata metadata) {
|
||||||
|
|
||||||
ElasticsearchEntityInformation<?, ?> entityInformation = getEntityInformation(metadata.getDomainType());
|
ElasticsearchEntityInformation<?, ?> entityInformation = getEntityInformation(metadata.getDomainType());
|
||||||
@ -117,5 +117,4 @@ public class ElasticsearchRepositoryFactory extends RepositoryFactorySupport {
|
|||||||
return new ElasticsearchPartQuery(queryMethod, elasticsearchOperations);
|
return new ElasticsearchPartQuery(queryMethod, elasticsearchOperations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,14 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.repository.support;
|
package org.springframework.data.elasticsearch.repository.support;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||||
import org.springframework.data.repository.Repository;
|
import org.springframework.data.repository.Repository;
|
||||||
import org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport;
|
import org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport;
|
||||||
import org.springframework.data.repository.core.support.RepositoryFactorySupport;
|
import org.springframework.data.repository.core.support.RepositoryFactorySupport;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring {@link org.springframework.beans.factory.FactoryBean} implementation to ease container based configuration for
|
* Spring {@link org.springframework.beans.factory.FactoryBean} implementation to ease container based configuration for
|
||||||
* XML namespace and JavaConfig.
|
* XML namespace and JavaConfig.
|
||||||
@ -59,5 +59,4 @@ public class ElasticsearchRepositoryFactoryBean<T extends Repository<S, ID>, S,
|
|||||||
protected RepositoryFactorySupport createRepositoryFactory() {
|
protected RepositoryFactorySupport createRepositoryFactory() {
|
||||||
return new ElasticsearchRepositoryFactory(operations);
|
return new ElasticsearchRepositoryFactory(operations);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ import org.springframework.util.Assert;
|
|||||||
*
|
*
|
||||||
* @param <T>
|
* @param <T>
|
||||||
* @param <ID>
|
* @param <ID>
|
||||||
*
|
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
* @author Ryan Henszey
|
* @author Ryan Henszey
|
||||||
|
@ -21,7 +21,6 @@ import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
|||||||
* Elasticsearch specific repository implementation. Likely to be used as target within
|
* Elasticsearch specific repository implementation. Likely to be used as target within
|
||||||
* {@link ElasticsearchRepositoryFactory}
|
* {@link ElasticsearchRepositoryFactory}
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
* @author Ryan Henszey
|
* @author Ryan Henszey
|
||||||
@ -45,5 +44,4 @@ public class NumberKeyedRepository<T, ID extends Number> extends AbstractElastic
|
|||||||
protected String stringIdRepresentation(ID id) {
|
protected String stringIdRepresentation(ID id) {
|
||||||
return String.valueOf(id);
|
return String.valueOf(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
|||||||
* Elasticsearch specific repository implementation. Likely to be used as target within
|
* Elasticsearch specific repository implementation. Likely to be used as target within
|
||||||
* {@link ElasticsearchRepositoryFactory}
|
* {@link ElasticsearchRepositoryFactory}
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
* @author Ryan Henszey
|
* @author Ryan Henszey
|
||||||
@ -45,5 +44,4 @@ public class SimpleElasticsearchRepository<T> extends AbstractElasticsearchRepos
|
|||||||
protected String stringIdRepresentation(String id) {
|
protected String stringIdRepresentation(String id) {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,17 +7,18 @@
|
|||||||
targetNamespace="http://www.springframework.org/schema/data/elasticsearch"
|
targetNamespace="http://www.springframework.org/schema/data/elasticsearch"
|
||||||
elementFormDefault="qualified" attributeFormDefault="unqualified">
|
elementFormDefault="qualified" attributeFormDefault="unqualified">
|
||||||
|
|
||||||
<xsd:import namespace="http://www.springframework.org/schema/beans" />
|
<xsd:import namespace="http://www.springframework.org/schema/beans"/>
|
||||||
<xsd:import namespace="http://www.springframework.org/schema/tool" />
|
<xsd:import namespace="http://www.springframework.org/schema/tool"/>
|
||||||
<xsd:import namespace="http://www.springframework.org/schema/data/repository"
|
<xsd:import namespace="http://www.springframework.org/schema/data/repository"
|
||||||
schemaLocation="http://www.springframework.org/schema/data/repository/spring-repository.xsd" />
|
schemaLocation="http://www.springframework.org/schema/data/repository/spring-repository.xsd"/>
|
||||||
|
|
||||||
<xsd:element name="repositories">
|
<xsd:element name="repositories">
|
||||||
<xsd:complexType>
|
<xsd:complexType>
|
||||||
<xsd:complexContent>
|
<xsd:complexContent>
|
||||||
<xsd:extension base="repository:repositories">
|
<xsd:extension base="repository:repositories">
|
||||||
<xsd:attributeGroup ref="repository:repository-attributes" />
|
<xsd:attributeGroup ref="repository:repository-attributes"/>
|
||||||
<xsd:attribute name="elasticsearch-template-ref" type="elasticsearchTemplateRef" default="elasticsearchTemplate" />
|
<xsd:attribute name="elasticsearch-template-ref" type="elasticsearchTemplateRef"
|
||||||
|
default="elasticsearchTemplate"/>
|
||||||
</xsd:extension>
|
</xsd:extension>
|
||||||
</xsd:complexContent>
|
</xsd:complexContent>
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
@ -27,16 +28,16 @@
|
|||||||
<xsd:annotation>
|
<xsd:annotation>
|
||||||
<xsd:appinfo>
|
<xsd:appinfo>
|
||||||
<tool:annotation kind="ref">
|
<tool:annotation kind="ref">
|
||||||
<tool:assignable-to type="org.springframework.data.elasticsearch.core.ElasticsearchTemplate" />
|
<tool:assignable-to type="org.springframework.data.elasticsearch.core.ElasticsearchTemplate"/>
|
||||||
</tool:annotation>
|
</tool:annotation>
|
||||||
</xsd:appinfo>
|
</xsd:appinfo>
|
||||||
</xsd:annotation>
|
</xsd:annotation>
|
||||||
<xsd:union memberTypes="xsd:string" />
|
<xsd:union memberTypes="xsd:string"/>
|
||||||
</xsd:simpleType>
|
</xsd:simpleType>
|
||||||
|
|
||||||
<xsd:element name="node-client">
|
<xsd:element name="node-client">
|
||||||
<xsd:annotation>
|
<xsd:annotation>
|
||||||
<xsd:documentation source="java: org.springframework.data.elasticsearch.client.NodeClientFactoryBean" />
|
<xsd:documentation source="java: org.springframework.data.elasticsearch.client.NodeClientFactoryBean"/>
|
||||||
<xsd:appinfo>
|
<xsd:appinfo>
|
||||||
<tool:assignable-to type="org.elasticsearch.client.Client"/>
|
<tool:assignable-to type="org.elasticsearch.client.Client"/>
|
||||||
</xsd:appinfo>
|
</xsd:appinfo>
|
||||||
@ -46,12 +47,14 @@
|
|||||||
<xsd:extension base="beans:identifiedType">
|
<xsd:extension base="beans:identifiedType">
|
||||||
<xsd:attribute name="local" type="xsd:boolean" default="false">
|
<xsd:attribute name="local" type="xsd:boolean" default="false">
|
||||||
<xsd:annotation>
|
<xsd:annotation>
|
||||||
<xsd:documentation><![CDATA[local here means local on the JVM (well, actually class loader) level, meaning that two local servers started within the same JVM will discover themselves and form a cluster]]></xsd:documentation>
|
<xsd:documentation>
|
||||||
|
<![CDATA[local here means local on the JVM (well, actually class loader) level, meaning that two local servers started within the same JVM will discover themselves and form a cluster]]></xsd:documentation>
|
||||||
</xsd:annotation>
|
</xsd:annotation>
|
||||||
</xsd:attribute>
|
</xsd:attribute>
|
||||||
<xsd:attribute name="cluster-name" type="xsd:string" default="elasticsearch">
|
<xsd:attribute name="cluster-name" type="xsd:string" default="elasticsearch">
|
||||||
<xsd:annotation>
|
<xsd:annotation>
|
||||||
<xsd:documentation><![CDATA[Name of the cluster in which this instance of node client will connect to]]> </xsd:documentation>
|
<xsd:documentation>
|
||||||
|
<![CDATA[Name of the cluster in which this instance of node client will connect to]]> </xsd:documentation>
|
||||||
</xsd:annotation>
|
</xsd:annotation>
|
||||||
</xsd:attribute>
|
</xsd:attribute>
|
||||||
<xsd:attribute name="http-enabled" type="xsd:boolean" default="true">
|
<xsd:attribute name="http-enabled" type="xsd:boolean" default="true">
|
||||||
@ -66,7 +69,7 @@
|
|||||||
|
|
||||||
<xsd:element name="transport-client">
|
<xsd:element name="transport-client">
|
||||||
<xsd:annotation>
|
<xsd:annotation>
|
||||||
<xsd:documentation source="java: org.springframework.data.elasticsearch.client.TransportClientFactoryBean" />
|
<xsd:documentation source="java: org.springframework.data.elasticsearch.client.TransportClientFactoryBean"/>
|
||||||
<xsd:appinfo>
|
<xsd:appinfo>
|
||||||
<tool:assignable-to type="org.elasticsearch.client.Client"/>
|
<tool:assignable-to type="org.elasticsearch.client.Client"/>
|
||||||
</xsd:appinfo>
|
</xsd:appinfo>
|
||||||
@ -76,32 +79,38 @@
|
|||||||
<xsd:extension base="beans:identifiedType">
|
<xsd:extension base="beans:identifiedType">
|
||||||
<xsd:attribute name="cluster-nodes" type="xsd:string" default="127.0.0.1:9300">
|
<xsd:attribute name="cluster-nodes" type="xsd:string" default="127.0.0.1:9300">
|
||||||
<xsd:annotation>
|
<xsd:annotation>
|
||||||
<xsd:documentation><![CDATA[The comma delimited list of host:port entries to use for elasticsearch cluster.]]></xsd:documentation>
|
<xsd:documentation>
|
||||||
|
<![CDATA[The comma delimited list of host:port entries to use for elasticsearch cluster.]]></xsd:documentation>
|
||||||
</xsd:annotation>
|
</xsd:annotation>
|
||||||
</xsd:attribute>
|
</xsd:attribute>
|
||||||
<xsd:attribute name="cluster-name" type="xsd:string" default="elasticsearch">
|
<xsd:attribute name="cluster-name" type="xsd:string" default="elasticsearch">
|
||||||
<xsd:annotation>
|
<xsd:annotation>
|
||||||
<xsd:documentation><![CDATA[Name of the cluster in which this instance of node client will connect to]]> </xsd:documentation>
|
<xsd:documentation>
|
||||||
|
<![CDATA[Name of the cluster in which this instance of node client will connect to]]> </xsd:documentation>
|
||||||
</xsd:annotation>
|
</xsd:annotation>
|
||||||
</xsd:attribute>
|
</xsd:attribute>
|
||||||
<xsd:attribute name="client-transport-sniff" type="xsd:boolean" default="true">
|
<xsd:attribute name="client-transport-sniff" type="xsd:boolean" default="true">
|
||||||
<xsd:annotation>
|
<xsd:annotation>
|
||||||
<xsd:documentation><![CDATA[The client allows to sniff the rest of the cluster, and add those into its list of machines to use.]]> </xsd:documentation>
|
<xsd:documentation>
|
||||||
|
<![CDATA[The client allows to sniff the rest of the cluster, and add those into its list of machines to use.]]> </xsd:documentation>
|
||||||
</xsd:annotation>
|
</xsd:annotation>
|
||||||
</xsd:attribute>
|
</xsd:attribute>
|
||||||
<xsd:attribute name="client-transport-ignore-cluster-name" type="xsd:boolean" default="false">
|
<xsd:attribute name="client-transport-ignore-cluster-name" type="xsd:boolean" default="false">
|
||||||
<xsd:annotation>
|
<xsd:annotation>
|
||||||
<xsd:documentation><![CDATA[Set to true to ignore cluster name validation of connected nodes. (since 0.19.4)]]> </xsd:documentation>
|
<xsd:documentation>
|
||||||
|
<![CDATA[Set to true to ignore cluster name validation of connected nodes. (since 0.19.4)]]> </xsd:documentation>
|
||||||
</xsd:annotation>
|
</xsd:annotation>
|
||||||
</xsd:attribute>
|
</xsd:attribute>
|
||||||
<xsd:attribute name="client-transport-ping-timeout" type="xsd:string" default="5s">
|
<xsd:attribute name="client-transport-ping-timeout" type="xsd:string" default="5s">
|
||||||
<xsd:annotation>
|
<xsd:annotation>
|
||||||
<xsd:documentation><![CDATA[The time to wait for a ping response from a node. Defaults to 5s.]]> </xsd:documentation>
|
<xsd:documentation>
|
||||||
|
<![CDATA[The time to wait for a ping response from a node. Defaults to 5s.]]> </xsd:documentation>
|
||||||
</xsd:annotation>
|
</xsd:annotation>
|
||||||
</xsd:attribute>
|
</xsd:attribute>
|
||||||
<xsd:attribute name="client-transport-nodes-sampler-interval" type="xsd:string" default="5s">
|
<xsd:attribute name="client-transport-nodes-sampler-interval" type="xsd:string" default="5s">
|
||||||
<xsd:annotation>
|
<xsd:annotation>
|
||||||
<xsd:documentation><![CDATA[How often to sample / ping the nodes listed and connected. Defaults to 5s.]]> </xsd:documentation>
|
<xsd:documentation>
|
||||||
|
<![CDATA[How often to sample / ping the nodes listed and connected. Defaults to 5s.]]> </xsd:documentation>
|
||||||
</xsd:annotation>
|
</xsd:annotation>
|
||||||
</xsd:attribute>
|
</xsd:attribute>
|
||||||
</xsd:extension>
|
</xsd:extension>
|
||||||
|
@ -32,7 +32,7 @@ public class CarBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Car build(){
|
public Car build() {
|
||||||
return car;
|
return car;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,5 +65,4 @@ public class DoubleIDEntity {
|
|||||||
public void setVersion(Long version) {
|
public void setVersion(Long version) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch;
|
package org.springframework.data.elasticsearch;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
||||||
import org.springframework.data.elasticsearch.annotations.FieldType;
|
import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
|
@ -65,5 +65,4 @@ public class IntegerIDEntity {
|
|||||||
public void setVersion(Long version) {
|
public void setVersion(Long version) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ package org.springframework.data.elasticsearch;
|
|||||||
|
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MinimalEntity
|
* MinimalEntity
|
||||||
*
|
*
|
||||||
@ -24,6 +25,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
|
|||||||
*/
|
*/
|
||||||
@Document(indexName = "index", type = "type")
|
@Document(indexName = "index", type = "type")
|
||||||
public class MinimalEntity {
|
public class MinimalEntity {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
private String id;
|
private String id;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch;
|
package org.springframework.data.elasticsearch;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang.RandomStringUtils.*;
|
||||||
|
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||||
|
import static org.hamcrest.Matchers.*;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@ -31,20 +40,6 @@ import org.springframework.data.elasticsearch.repositories.SampleElasticSearchBo
|
|||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
|
|
||||||
import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
|
|
||||||
import static org.elasticsearch.index.query.QueryBuilders.nestedQuery;
|
|
||||||
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
|
|
||||||
import static org.hamcrest.Matchers.is;
|
|
||||||
import static org.hamcrest.Matchers.notNullValue;
|
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
@ -54,7 +49,7 @@ import static org.junit.Assert.assertThat;
|
|||||||
@ContextConfiguration("classpath:/repository-test-nested-object.xml")
|
@ContextConfiguration("classpath:/repository-test-nested-object.xml")
|
||||||
public class NestedObjectTests {
|
public class NestedObjectTests {
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
private SampleElasticSearchBookRepository bookRepository;
|
private SampleElasticSearchBookRepository bookRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -73,11 +68,11 @@ public class NestedObjectTests {
|
|||||||
elasticsearchTemplate.deleteIndex(PersonMultipleLevelNested.class);
|
elasticsearchTemplate.deleteIndex(PersonMultipleLevelNested.class);
|
||||||
elasticsearchTemplate.createIndex(PersonMultipleLevelNested.class);
|
elasticsearchTemplate.createIndex(PersonMultipleLevelNested.class);
|
||||||
elasticsearchTemplate.putMapping(PersonMultipleLevelNested.class);
|
elasticsearchTemplate.putMapping(PersonMultipleLevelNested.class);
|
||||||
elasticsearchTemplate.refresh(PersonMultipleLevelNested.class,true);
|
elasticsearchTemplate.refresh(PersonMultipleLevelNested.class, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldIndexInitialLevelNestedObject(){
|
public void shouldIndexInitialLevelNestedObject() {
|
||||||
|
|
||||||
List<Car> cars = new ArrayList<Car>();
|
List<Car> cars = new ArrayList<Car>();
|
||||||
|
|
||||||
@ -102,7 +97,6 @@ public class NestedObjectTests {
|
|||||||
foo.setId("1");
|
foo.setId("1");
|
||||||
foo.setCar(cars);
|
foo.setCar(cars);
|
||||||
|
|
||||||
|
|
||||||
Car car = new Car();
|
Car car = new Car();
|
||||||
car.setName("Saturn");
|
car.setName("Saturn");
|
||||||
car.setModel("Imprezza");
|
car.setModel("Imprezza");
|
||||||
@ -133,12 +127,11 @@ public class NestedObjectTests {
|
|||||||
SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(builder).build();
|
SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(builder).build();
|
||||||
List<Person> persons = elasticsearchTemplate.queryForList(searchQuery, Person.class);
|
List<Person> persons = elasticsearchTemplate.queryForList(searchQuery, Person.class);
|
||||||
|
|
||||||
assertThat(persons.size() , is(1));
|
assertThat(persons.size(), is(1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldIndexMultipleLevelNestedObject(){
|
public void shouldIndexMultipleLevelNestedObject() {
|
||||||
//given
|
//given
|
||||||
List<IndexQuery> indexQueries = createPerson();
|
List<IndexQuery> indexQueries = createPerson();
|
||||||
|
|
||||||
@ -155,7 +148,7 @@ public class NestedObjectTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldSearchUsingNestedQueryOnMultipleLevelNestedObject(){
|
public void shouldSearchUsingNestedQueryOnMultipleLevelNestedObject() {
|
||||||
//given
|
//given
|
||||||
List<IndexQuery> indexQueries = createPerson();
|
List<IndexQuery> indexQueries = createPerson();
|
||||||
|
|
||||||
@ -166,7 +159,7 @@ public class NestedObjectTests {
|
|||||||
|
|
||||||
//then
|
//then
|
||||||
BoolQueryBuilder builder = boolQuery();
|
BoolQueryBuilder builder = boolQuery();
|
||||||
builder.must(nestedQuery("girlFriends", termQuery("girlFriends.type","temp")))
|
builder.must(nestedQuery("girlFriends", termQuery("girlFriends.type", "temp")))
|
||||||
.must(nestedQuery("girlFriends.cars", termQuery("girlFriends.cars.name", "Ford".toLowerCase())));
|
.must(nestedQuery("girlFriends.cars", termQuery("girlFriends.cars.name", "Ford".toLowerCase())));
|
||||||
|
|
||||||
SearchQuery searchQuery = new NativeSearchQueryBuilder()
|
SearchQuery searchQuery = new NativeSearchQueryBuilder()
|
||||||
@ -196,7 +189,7 @@ public class NestedObjectTests {
|
|||||||
assertThat(bookRepository.findOne(id), is(notNullValue()));
|
assertThat(bookRepository.findOne(id), is(notNullValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<IndexQuery> createPerson(){
|
private List<IndexQuery> createPerson() {
|
||||||
|
|
||||||
PersonMultipleLevelNested person1 = new PersonMultipleLevelNested();
|
PersonMultipleLevelNested person1 = new PersonMultipleLevelNested();
|
||||||
|
|
||||||
@ -227,7 +220,7 @@ public class NestedObjectTests {
|
|||||||
GirlFriend temp = new GirlFriend();
|
GirlFriend temp = new GirlFriend();
|
||||||
temp.setName("temp");
|
temp.setName("temp");
|
||||||
temp.setType("temp");
|
temp.setType("temp");
|
||||||
temp.setCars(Arrays.asList(car,ford));
|
temp.setCars(Arrays.asList(car, ford));
|
||||||
|
|
||||||
person1.setGirlFriends(Arrays.asList(permanent, temp));
|
person1.setGirlFriends(Arrays.asList(permanent, temp));
|
||||||
|
|
||||||
@ -235,7 +228,6 @@ public class NestedObjectTests {
|
|||||||
indexQuery1.setId(person1.getId());
|
indexQuery1.setId(person1.getId());
|
||||||
indexQuery1.setObject(person1);
|
indexQuery1.setObject(person1);
|
||||||
|
|
||||||
|
|
||||||
PersonMultipleLevelNested person2 = new PersonMultipleLevelNested();
|
PersonMultipleLevelNested person2 = new PersonMultipleLevelNested();
|
||||||
|
|
||||||
person2.setId("2");
|
person2.setId("2");
|
||||||
@ -252,6 +244,5 @@ public class NestedObjectTests {
|
|||||||
indexQueries.add(indexQuery2);
|
indexQueries.add(indexQuery2);
|
||||||
|
|
||||||
return indexQueries;
|
return indexQueries;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ package org.springframework.data.elasticsearch;
|
|||||||
import org.springframework.core.style.ToStringCreator;
|
import org.springframework.core.style.ToStringCreator;
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.elasticsearch.annotations.*;
|
import org.springframework.data.elasticsearch.annotations.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ParentEntity
|
* ParentEntity
|
||||||
*
|
*
|
||||||
@ -26,6 +27,7 @@ import org.springframework.data.elasticsearch.annotations.*;
|
|||||||
*/
|
*/
|
||||||
@Document(indexName = ParentEntity.INDEX, type = ParentEntity.PARENT_TYPE, indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
|
@Document(indexName = ParentEntity.INDEX, type = ParentEntity.PARENT_TYPE, indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
|
||||||
public class ParentEntity {
|
public class ParentEntity {
|
||||||
|
|
||||||
public static final String INDEX = "parent-child";
|
public static final String INDEX = "parent-child";
|
||||||
public static final String PARENT_TYPE = "parent-entity";
|
public static final String PARENT_TYPE = "parent-entity";
|
||||||
public static final String CHILD_TYPE = "child-entity";
|
public static final String CHILD_TYPE = "child-entity";
|
||||||
@ -58,6 +60,7 @@ public class ParentEntity {
|
|||||||
|
|
||||||
@Document(indexName = INDEX, type = CHILD_TYPE, indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
|
@Document(indexName = INDEX, type = CHILD_TYPE, indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
|
||||||
public static class ChildEntity {
|
public static class ChildEntity {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
private String id;
|
private String id;
|
||||||
@Field(type = FieldType.String, store = true)
|
@Field(type = FieldType.String, store = true)
|
||||||
|
@ -16,20 +16,20 @@
|
|||||||
package org.springframework.data.elasticsearch;
|
package org.springframework.data.elasticsearch;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
||||||
import org.springframework.data.elasticsearch.annotations.FieldType;
|
import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Document( indexName = "person" , type = "user", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
|
@Document(indexName = "person", type = "user", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
|
||||||
public class Person {
|
public class Person {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@ -37,7 +37,7 @@ public class Person {
|
|||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Field( type = FieldType.Nested)
|
@Field(type = FieldType.Nested)
|
||||||
private List<Car> car;
|
private List<Car> car;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
@ -16,20 +16,20 @@
|
|||||||
package org.springframework.data.elasticsearch;
|
package org.springframework.data.elasticsearch;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
||||||
import org.springframework.data.elasticsearch.annotations.FieldType;
|
import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Document( indexName = "person-multiple-level-nested" , type = "user", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
|
@Document(indexName = "person-multiple-level-nested", type = "user", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
|
||||||
public class PersonMultipleLevelNested {
|
public class PersonMultipleLevelNested {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch;
|
package org.springframework.data.elasticsearch;
|
||||||
|
|
||||||
import org.springframework.data.annotation.Id;
|
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.data.annotation.Id;
|
||||||
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
@ -174,5 +174,4 @@ public class Product {
|
|||||||
public void setText(String text) {
|
public void setText(String text) {
|
||||||
this.text = text;
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
package org.springframework.data.elasticsearch;
|
package org.springframework.data.elasticsearch;
|
||||||
|
|
||||||
|
import static org.springframework.data.elasticsearch.annotations.FieldIndex.*;
|
||||||
|
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||||
|
import static org.springframework.data.elasticsearch.annotations.FieldType.String;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.elasticsearch.annotations.DateFormat;
|
import org.springframework.data.elasticsearch.annotations.DateFormat;
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import static org.springframework.data.elasticsearch.annotations.FieldIndex.not_analyzed;
|
|
||||||
import static org.springframework.data.elasticsearch.annotations.FieldType.String;
|
|
||||||
import static org.springframework.data.elasticsearch.annotations.FieldType.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jakub Vavrik
|
* @author Jakub Vavrik
|
||||||
*/
|
*/
|
||||||
@Document(indexName = "test-datemapping", type = "mapping", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
|
@Document(indexName = "test-datemapping", type = "mapping", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
|
||||||
public class SampleDateMappingEntity {
|
public class SampleDateMappingEntity {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
@ -15,14 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch;
|
package org.springframework.data.elasticsearch;
|
||||||
|
|
||||||
|
import static org.springframework.data.elasticsearch.annotations.FieldIndex.*;
|
||||||
|
import static org.springframework.data.elasticsearch.annotations.FieldType.String;
|
||||||
|
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
||||||
import org.springframework.data.elasticsearch.annotations.FieldIndex;
|
|
||||||
import org.springframework.data.elasticsearch.annotations.FieldType;
|
|
||||||
|
|
||||||
import static org.springframework.data.elasticsearch.annotations.FieldIndex.*;
|
|
||||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
@ -56,6 +54,7 @@ public class SampleMappingEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static class NestedEntity {
|
static class NestedEntity {
|
||||||
|
|
||||||
@Field(type = String)
|
@Field(type = String)
|
||||||
private String someField;
|
private String someField;
|
||||||
|
|
||||||
@ -67,5 +66,4 @@ public class SampleMappingEntity {
|
|||||||
this.someField = someField;
|
this.someField = someField;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,14 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch;
|
package org.springframework.data.elasticsearch;
|
||||||
|
|
||||||
|
import static org.springframework.data.elasticsearch.annotations.FieldIndex.*;
|
||||||
|
import static org.springframework.data.elasticsearch.annotations.FieldType.String;
|
||||||
|
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.annotation.Transient;
|
import org.springframework.data.annotation.Transient;
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
||||||
|
|
||||||
import static org.springframework.data.elasticsearch.annotations.FieldIndex.not_analyzed;
|
|
||||||
import static org.springframework.data.elasticsearch.annotations.FieldType.String;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jakub Vavrik
|
* @author Jakub Vavrik
|
||||||
*/
|
*/
|
||||||
@ -55,6 +55,7 @@ public class SampleTransientEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static class NestedEntity {
|
static class NestedEntity {
|
||||||
|
|
||||||
@Field
|
@Field
|
||||||
private static NestedEntity someField = new NestedEntity();
|
private static NestedEntity someField = new NestedEntity();
|
||||||
@Field
|
@Field
|
||||||
@ -68,9 +69,12 @@ public class SampleTransientEntity {
|
|||||||
this.someField = someField;
|
this.someField = someField;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getSomething() { return something; }
|
public Boolean getSomething() {
|
||||||
|
return something;
|
||||||
public void setSomething(Boolean something) { this.something = something; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSomething(Boolean something) {
|
||||||
|
this.something = something;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
|
|||||||
* @author Stuart Stevenson
|
* @author Stuart Stevenson
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
*/
|
*/
|
||||||
@Document(indexName = "circular-objects", type = "circular-object" , indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
|
@Document(indexName = "circular-objects", type = "circular-object", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
|
||||||
public class SimpleRecursiveEntity {
|
public class SimpleRecursiveEntity {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@ -15,13 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch;
|
package org.springframework.data.elasticsearch;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
||||||
import org.springframework.data.elasticsearch.annotations.FieldType;
|
import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
@ -37,7 +37,7 @@ public class StockPrice {
|
|||||||
@Field(type = FieldType.Double)
|
@Field(type = FieldType.Double)
|
||||||
private BigDecimal price;
|
private BigDecimal price;
|
||||||
|
|
||||||
private StockPrice(){
|
private StockPrice() {
|
||||||
//don't delete
|
//don't delete
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch;
|
package org.springframework.data.elasticsearch;
|
||||||
|
|
||||||
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user