# Searching with multiple values - JAVA

**URL:** <https://discuss.elastic.co/t/searching-with-multiple-values-java/43937>\
**Category:** Elasticsearch\
**Created:** [March 9, 2016, 7:03pm UTC](https://discuss.elastic.co/t/searching-with-multiple-values-java/43937 "2016-03-09T19:03:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![issam](https://avatars.discourse-cdn.com/v4/letter/i/f05b48/32.png) [@issam](https://discuss.elastic.co/u/issam)\
**Post date:** [March 9, 2016, 7:03pm UTC](https://discuss.elastic.co/t/searching-with-multiple-values-java/43937/1 "2016-03-09T19:03:17Z")

</div>

Hello,

I have to search on the indexes already created with multiple values in a given field, but I always get nothing in the result

Can you tell please if it is ok with the following code (I use elasticsearch Java API)

- query = QueryBuilders.termsQuery(param, values);
- boolQueryBuilder.must(query);

I have something like that in boolQueryBuilder

- {
- "bool" : {
- 

```
"must" : [ {

```

- 

```
  "terms" : {

```

- 

```
    "param1" : [value1, value2, value3]

```

- 

```
  }

```

- 

```
}, {

```

- 

```
  "wildcard" : {

```

- 

```
    "param2" : "*"

```

- 

```
  }

```

- 

```
} ]

```

I'm sure, that value1, 2 & 3 already exist, but I always get nothing, is there anyone who has an idea please ?

Thank you

---

<div class="post-metadata">

**Author:** ![issam](https://avatars.discourse-cdn.com/v4/letter/i/f05b48/32.png) [@issam](https://discuss.elastic.co/u/issam)\
**Post date:** [March 9, 2016, 7:23pm UTC](https://discuss.elastic.co/t/searching-with-multiple-values-java/43937/2 "2016-03-09T19:23:43Z")

</div>

well, that was quickly, it is ok with using the termsQuery search with many values in one a single field, the problem here, is that my values contain "-" wich is a special character, so elasticsearch replace it with space (I think)

If any one has an answer, for this problem (special characters) I'll be really thankful

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [March 9, 2016, 9:00pm UTC](https://discuss.elastic.co/t/searching-with-multiple-values-java/43937/3 "2016-03-09T21:00:18Z")

</div>

Take a look at the different [Tokenizers](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-tokenizers.html), the default is the [Standard tokenizer](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-standard-tokenizer.html) which splits on some characters (as you have seen). Maybe start with the [Whitespace tokenizer](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-whitespace-tokenizer.html) instead.

---

<div class="post-metadata">

**Author:** ![issam](https://avatars.discourse-cdn.com/v4/letter/i/f05b48/32.png) [@issam](https://discuss.elastic.co/u/issam)\
**Post date:** [March 10, 2016, 5:16pm UTC](https://discuss.elastic.co/t/searching-with-multiple-values-java/43937/4 "2016-03-10T17:16:03Z")

</div>

Thank you for Christoph, I found how to modify the tokenizer to whistespace one (using JAVA) but now, the wildcard terms are not working anymore, '\*' and '?' are not considered token chars anymore, which is not good because I need these characters in my search

Is there anyway to keep '\*' and '?' and remove only other characters such as '-' and '@' from token chars ??

Thank you

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [March 11, 2016, 2:18pm UTC](https://discuss.elastic.co/t/searching-with-multiple-values-java/43937/5 "2016-03-11T14:18:58Z")

</div>

> [@issam](#):
>
> "wildcard" : {  
> "param2" : "\*"  
> }

I'm afraid I'm not sure I understand what you are trying to do here. This wildcard query basically matches everything in the `param2` field. Also I don't quiet understand what you mean by "'\*' and '?' are not considered token chars anymore". Maybe you can give an example of a document you are trying to find and which isn't returned by the query you are using?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:09pm UTC](https://discuss.elastic.co/t/searching-with-multiple-values-java/43937/6 "2017-07-05T23:09:09Z")

</div>

Closed on July 5, 2017, 11:09pm UTC


