Skip to content

Added the String Contains Ignorecase criteria support #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<module>querydsl-dynamodb</module>
<module>querydsl-hazelcast</module>
<module>querydsl-elasticsearch</module>
<module>querydsl-elasticsearch2</module>
</modules>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ public Object visit(Operation<?> expr, @Nullable BoolQueryBuilder context) {
String value = StringUtils.toString(asDBValue(expr, 1));
return QueryBuilders.queryString("*" + value + "*").field(asDBKey(expr, 0)).analyzeWildcard(true);

} else if (op == Ops.STRING_CONTAINS_IC) {
String value = StringUtils.toString(asDBValue(expr, 1));
return QueryBuilders.queryString("*" + value + "*").field(asDBKey(expr, 0)).analyzer("standard").analyzeWildcard(true);

} else if (op == Ops.NOT) {
// Handle the not's child
BoolQueryBuilder subContext = QueryBuilders.boolQuery();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ public void NotContains() {
//assertQuery(user.friends.contains(u1).not(), u1);
}

@Test
public void Contains_Ignore_Case() {
assertTrue(where(user.firstName.containsIgnoreCase("akk")).fetchCount() > 0);
}

@Test
public void Contains_Ignore_Case_2() {
assertFalse(where(user.firstName.containsIgnoreCase("xyzzz")).fetchCount() > 0);
}

@Test
public void Equals_Ignore_Case() {
assertTrue(where(user.firstName.equalsIgnoreCase("jAaKko")).fetchCount() > 0);
Expand Down
159 changes: 159 additions & 0 deletions querydsl-elasticsearch2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
<?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">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.querydsl.contrib</groupId>
<artifactId>querydsl-contrib</artifactId>
<version>4.0.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>querydsl-elasticsearch2</artifactId>
<name>Querydsl - Elasticsearch 2 support</name>
<description>Elasticsearch 2 support for Querydsl</description>
<packaging>jar</packaging>
<url>${project.homepage}</url>

<scm>
<connection>${project.checkout}</connection>
<developerConnection>${project.checkout}</developerConnection>
<url>${project.githubpage}</url>
</scm>

<properties>
<elasticsearch.version>2.1.0</elasticsearch.version>
<jackson.version>2.6.3</jackson.version>
<osgi.import.package>
org.elasticsearch.*;version="0.0.0",
com.fasterxml.jackson.core.*;version="0.0.0",
${osgi.import.package.root}
</osgi.import.package>
</properties>

<dependencies>

<!-- Elasticsearch -->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${elasticsearch.version}</version>
</dependency>

<!-- Jackson JSON Mapper -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>

<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.springsource.bundlor</groupId>
<artifactId>com.springsource.bundlor.maven</artifactId>
</plugin>

<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-test-sources</phase>
<goals>
<goal>test-process</goal>
<goal>add-test-sources</goal>
</goals>
<configuration>
<outputDirectory>target/generated-test-sources/java</outputDirectory>
<processor>com.querydsl.apt.QuerydslAnnotationProcessor</processor>
<options>
<defaultOverwrite>true</defaultOverwrite>
</options>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>extra-jars</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptors>
<descriptor>src/main/apt.xml</descriptor>
<descriptor>src/main/assembly.xml</descriptor>
</descriptors>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>verification</id>
<goals>
<goal>test</goal>
</goals>
<phase>verify</phase>
<configuration>
<systemProperties>
<property>
<name>version</name>
<value>${project.version}</value>
</property>
</systemProperties>
<includes>
<include>com/mysema/query/PackageVerification.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>

<developers>
<developer>
<id>kevinleturc</id>
<name>Kevin Leturc</name>
<email>[email protected]</email>
<roles>
<role>donator</role>
</roles>
</developer>
<developer>
<id>gkathire</id>
<name>Guru Kathiresan</name>
<email>[email protected]</email>
<roles>
<role>donator</role>
</roles>
</developer>
</developers>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.mysema.query.apt.QuerydslAnnotationProcessor
19 changes: 19 additions & 0 deletions querydsl-elasticsearch2/src/main/apt.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>apt</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>src/apt</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.build.outputDirectory}</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
</assembly>
25 changes: 25 additions & 0 deletions querydsl-elasticsearch2/src/main/assembly.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>apt-one-jar</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>src/apt</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
<fileSet>
<directory>src/license</directory>
<outputDirectory>/license</outputDirectory>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<unpack>true</unpack>
</dependencySet>
</dependencySets>
</assembly>

Loading