001package io.ebean.search; 002 003/** 004 * Simple text query options. 005 * <p> 006 * This maps to an ElasticSearch "simple text query". 007 * </p> 008 * <pre>{@code 009 * 010 * TextSimple options = new TextSimple() 011 * .analyzeWildcard(true) 012 * .fields("name") 013 * .lenient(true) 014 * .opAnd(); 015 * 016 * List<Customer> customers = database.find(Customer.class) 017 * .text() 018 * .textSimple("quick brown", options) 019 * .findList(); 020 * 021 * }</pre> 022 */ 023public class TextSimple { 024 025 protected String[] fields; 026 027 protected boolean operatorAnd; 028 029 protected String analyzer; 030 031 protected String flags; 032 033 protected boolean lowercaseExpandedTerms = true; 034 035 protected boolean analyzeWildcard; 036 037 protected String locale; 038 039 protected boolean lenient; 040 041 protected String minShouldMatch; 042 043 /** 044 * Construct 045 */ 046 public TextSimple() { 047 } 048 049 /** 050 * Set the fields. 051 */ 052 public TextSimple fields(String... fields) { 053 this.fields = fields; 054 return this; 055 } 056 057 /** 058 * Use AND as the default operator. 059 */ 060 public TextSimple opAnd() { 061 this.operatorAnd = true; 062 return this; 063 } 064 065 /** 066 * Use OR as the default operator. 067 */ 068 public TextSimple opOr() { 069 this.operatorAnd = false; 070 return this; 071 } 072 073 /** 074 * Set the analyzer 075 */ 076 public TextSimple analyzer(String analyzer) { 077 this.analyzer = analyzer; 078 return this; 079 } 080 081 /** 082 * Set the flags. 083 */ 084 public TextSimple flags(String flags) { 085 this.flags = flags; 086 return this; 087 } 088 089 090 /** 091 * Set the false to not use lowercase expanded terms. 092 */ 093 public TextSimple lowercaseExpandedTerms(boolean lowercaseExpandedTerms) { 094 this.lowercaseExpandedTerms = lowercaseExpandedTerms; 095 return this; 096 } 097 098 /** 099 * Set to true to use analyze wildcard. 100 */ 101 public TextSimple analyzeWildcard(boolean analyzeWildcard) { 102 this.analyzeWildcard = analyzeWildcard; 103 return this; 104 } 105 106 /** 107 * Set the locale. 108 */ 109 public TextSimple locale(String locale) { 110 this.locale = locale; 111 return this; 112 } 113 114 /** 115 * Set the lenient mode. 116 */ 117 public TextSimple lenient(boolean lenient) { 118 this.lenient = lenient; 119 return this; 120 } 121 122 /** 123 * Set the minimum should match. 124 */ 125 public TextSimple minShouldMatch(String minShouldMatch) { 126 this.minShouldMatch = minShouldMatch; 127 return this; 128 } 129 130 /** 131 * Return lenient mode. 132 */ 133 public boolean isLenient() { 134 return lenient; 135 } 136 137 /** 138 * Return true to analyse wildcard. 139 */ 140 public boolean isAnalyzeWildcard() { 141 return analyzeWildcard; 142 } 143 144 /** 145 * Return lowercase expanded terms mode. 146 */ 147 public boolean isLowercaseExpandedTerms() { 148 return lowercaseExpandedTerms; 149 } 150 151 /** 152 * Return true if the default operator should be AND. 153 */ 154 public boolean isOperatorAnd() { 155 return operatorAnd; 156 } 157 158 /** 159 * Return the analyzer to use. 160 */ 161 public String getAnalyzer() { 162 return analyzer; 163 } 164 165 /** 166 * Return the fields. 167 */ 168 public String[] getFields() { 169 return fields; 170 } 171 172 /** 173 * Return the locale. 174 */ 175 public String getLocale() { 176 return locale; 177 } 178 179 /** 180 * Return the flags. 181 */ 182 public String getFlags() { 183 return flags; 184 } 185 186 /** 187 * Return the minimum should match. 188 */ 189 public String getMinShouldMatch() { 190 return minShouldMatch; 191 } 192 193}