# Search for URIs which match a server

**URL:** https://discuss.elastic.co/t/search-for-uris-which-match-a-server/13701
**Category:** Elasticsearch
**Created:** [September 20, 2013, 10:24am UTC](https://discuss.elastic.co/t/search-for-uris-which-match-a-server/13701 "2013-09-20T10:24:51Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Andreas\_Jaekle](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andreas_jaekle/32/1548_2.png) [@Andreas\_Jaekle](https://discuss.elastic.co/u/Andreas_Jaekle)
#### Post date: [September 20, 2013, 10:24am UTC](https://discuss.elastic.co/t/search-for-uris-which-match-a-server/13701/1 "2013-09-20T10:24:51Z")

</div>

hi,  
im trying to search for URIs which are on one domain. But the search always  
fails at the ":"  
How can i search for all URIs which start with "[http://abc.xyz/](http://abc.xyz/)"

curl -XPOST '[http://localhost:9200/test/test/1](http://localhost:9200/test/test/1)' --data '{uri:  
"[http://abc.def/abc](http://abc.def/abc)" [http://abc.def/abc](http://abc.def/abc)}'

curl -XPOST '[http://localhost:9200/test/test/2](http://localhost:9200/test/test/2)' --data '{uri:  
"[http://abc.xyz/abc](http://abc.xyz/abc)" [http://abc.xyz/abc](http://abc.xyz/abc)}'

curl -XPOST '[http://localhost:9200/test/test/3](http://localhost:9200/test/test/3)' --data '{uri:  
"[http://abc.ijk/abc](http://abc.ijk/abc)" [http://abc.ijk/abc](http://abc.ijk/abc)}'

curl '[http://localhost:9200/test/\_search?pretty=true](http://localhost:9200/test/_search?pretty=true)' --data  
'{"query":{"constant\_score":{"filter":[{"prefix":{"uri":"http\*:\*"}}],"must\_not":[],"should":[]}},"from":0,"size":10,"sort":[],"facets":{}}'

This query won't work, even if i escape the : with \

Any ideas ?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![johtani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johtani/32/44956_2.png) [@johtani](https://discuss.elastic.co/u/johtani)
#### Post date: [September 20, 2013, 4:24pm UTC](https://discuss.elastic.co/t/search-for-uris-which-match-a-server/13701/2 "2013-09-20T16:24:20Z")

</div>

Hi Andreas,

Maybe, you use default setting, that analyzer is standard analyzer.  
':' is not indexed, if you use standard analyzer

Do you run following command?  
It's response how to analyze uri field in Elasticsearch.

curl -XPOST '[http://localhost:9200/url\_test/\_analyze?pretty=true&field=uri](http://localhost:9200/url_test/_analyze?pretty=true&field=uri)' --data '[http://abc.xyz/abc](http://abc.xyz/abc)'

Probably, you get the following response.

{  
"tokens" : [ {  
"token" : "http",  
"start\_offset" : 0,  
"end\_offset" : 4,  
"type" : "",  
"position" : 1  
}, {  
"token" : "abc.xyz",  
"start\_offset" : 7,  
"end\_offset" : 14,  
"type" : "",  
"position" : 2  
}, {  
"token" : "abc",  
"start\_offset" : 15,  
"end\_offset" : 18,  
"type" : "",  
"position" : 3  
} ]  
}

If you do not want analyze uri field, you use following mappings to create index.

curl -XPUT 'localhost:9200/url\_test' -d '{  
"mappings": {  
"sample":{  
"properties" : {  
"uri" : {  
"type": "string",  
"index": "not\_analyzed"  
}  
}  
}  
}  
}'

Regards

* * *

Jun Ohtani  
[johtani@gmail.com](mailto:johtani@gmail.com)  
blog(japanese) : [http://blog.johtani.info](http://blog.johtani.info)  
twitter : [http://twitter.com/johtani](http://twitter.com/johtani)

On 2013/09/20, at 19:24, Andreas Jaekle [andreas.jaekle@gmail.com](mailto:andreas.jaekle@gmail.com) wrote:

> hi,  
> im trying to search for URIs which are on one domain. But the search always fails at the ":"  
> How can i search for all URIs which start with "[http://abc.xyz/](http://abc.xyz/)"
> 
> curl -XPOST '[http://localhost:9200/test/test/1](http://localhost:9200/test/test/1)' --data '{uri:"[http://abc.def/abc](http://abc.def/abc)"}'
> 
> curl -XPOST '[http://localhost:9200/test/test/2](http://localhost:9200/test/test/2)' --data '{uri:"[http://abc.xyz/abc](http://abc.xyz/abc)"}'
> 
> curl -XPOST '[http://localhost:9200/test/test/3](http://localhost:9200/test/test/3)' --data '{uri:"[http://abc.ijk/abc](http://abc.ijk/abc)"}'
> 
> curl '[http://localhost:9200/test/\_search?pretty=true](http://localhost:9200/test/_search?pretty=true)' --data '{"query":{"constant\_score":{"filter":[{"prefix":{"uri":"http:"}}],"must\_not":,"should":}},"from":0,"size":10,"sort":,"facets":{}}'
> 
> This query won't work, even if i escape the : with \
> 
> Any ideas ?
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Andreas\_Jaekle](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andreas_jaekle/32/1548_2.png) [@Andreas\_Jaekle](https://discuss.elastic.co/u/Andreas_Jaekle)
#### Post date: [September 23, 2013, 1:43pm UTC](https://discuss.elastic.co/t/search-for-uris-which-match-a-server/13701/3 "2013-09-23T13:43:55Z")

</div>

hi,  
i tried it, but it is not working.  
this is my test script:

IP=127.0.0.1

curl -XPUT "$IP:9200/test" -d '{  
"mappings": {  
"sample":{  
"properties" : {  
"uri" : {  
"type": "string",  
"index": "not\_analyzed"  
}  
}  
}  
}  
}'

echo ""  
echo "------------------------------------------------"  
curl -XPOST "http://:9200$IP/test/test/1" --data  
'{uri:"[http://abc.def/abc",value:"abc](http://abc.def/abc%22,value:%22abc)"}'  
echo ""  
curl -XPOST "http://:9200$IP/test/test/2" --data  
'{uri:"[http://abc.xyz/abc",value:"def](http://abc.xyz/abc%22,value:%22def)"}'  
echo ""  
curl -XPOST "http://:9200$IP/test/test/3" --data  
'{uri:"[http://abc.ijk/abc",value:"ijk](http://abc.ijk/abc%22,value:%22ijk)"}'

sleep 2  
echo ""  
echo "------------------------------------------------ simple prefix  
search:"  
curl "http://:9200$IP/test/\_search?pretty=true" --data  
'{"query":{"constant\_score":{"filter":[{"prefix":{"uri":"http"}}]}},"from":0,"size":10,"sort":,"facets":{}}'

echo ""  
echo "------------------------------------------------ search (not  
working):"  
curl "http://:9200$IP/test/\_search?pretty=true" --data  
'{"query":{"constant\_score":{"filter":[{"prefix":{"uri":"http:"}}]}},"from":0,"size":10,"sort":,"facets":{}}'

echo ""  
echo "------------------------------------------------ all"  
curl "http://:9200$IP/test/\_search?pretty=true"  
echo ""  
echo "------------------------------------------------ mapping"  
curl "http://:9200$IP/\_mapping?pretty=true"

Am 20.09.2013 18:24, schrieb Jun Ohtani:

> Hi Andreas,
> 
> Maybe, you use default setting, that analyzer is standard analyzer.  
> ':' is not indexed, if you use standard analyzer
> 
> Do you run following command?  
> It's response how to analyze uri field in Elasticsearch.
> 
> curl -XPOST '[http://localhost:9200/url\_test/\_analyze?pretty=true&field=uri](http://localhost:9200/url_test/_analyze?pretty=true&field=uri)' --data '[http://abc.xyz/abc](http://abc.xyz/abc)'
> 
> Probably, you get the following response.
> 
> {  
> "tokens" : [ {  
> "token" : "http",  
> "start\_offset" : 0,  
> "end\_offset" : 4,  
> "type" : "",  
> "position" : 1  
> }, {  
> "token" : "abc.xyz",  
> "start\_offset" : 7,  
> "end\_offset" : 14,  
> "type" : "",  
> "position" : 2  
> }, {  
> "token" : "abc",  
> "start\_offset" : 15,  
> "end\_offset" : 18,  
> "type" : "",  
> "position" : 3  
> } ]  
> }
> 
> If you do not want analyze uri field, you use following mappings to create index.
> 
> curl -XPUT 'localhost:9200/url\_test' -d '{  
> "mappings": {  
> "sample":{  
> "properties" : {  
> "uri" : {  
> "type": "string",  
> "index": "not\_analyzed"  
> }  
> }  
> }  
> }  
> }'
> 
> Regards
> 
> * * *
> 
> Jun Ohtani  
> [johtani@gmail.com](mailto:johtani@gmail.com)  
> blog(japanese) : [http://blog.johtani.info](http://blog.johtani.info)  
> twitter : [http://twitter.com/johtani](http://twitter.com/johtani)
> 
> On 2013/09/20, at 19:24, Andreas Jaekle [andreas.jaekle@gmail.com](mailto:andreas.jaekle@gmail.com) wrote:
> 
> > hi,  
> > im trying to search for URIs which are on one domain. But the search always fails at the ":"  
> > How can i search for all URIs which start with "[http://abc.xyz/](http://abc.xyz/)"
> > 
> > curl -XPOST '[http://localhost:9200/test/test/1](http://localhost:9200/test/test/1)' --data '{uri:"[http://abc.def/abc](http://abc.def/abc)"}'
> > 
> > curl -XPOST '[http://localhost:9200/test/test/2](http://localhost:9200/test/test/2)' --data '{uri:"[http://abc.xyz/abc](http://abc.xyz/abc)"}'
> > 
> > curl -XPOST '[http://localhost:9200/test/test/3](http://localhost:9200/test/test/3)' --data '{uri:"[http://abc.ijk/abc](http://abc.ijk/abc)"}'
> > 
> > curl '[http://localhost:9200/test/\_search?pretty=true](http://localhost:9200/test/_search?pretty=true)' --data '{"query":{"constant\_score":{"filter":[{"prefix":{"uri":"http:"}}],"must\_not":,"should":}},"from":0,"size":10,"sort":,"facets":{}}'
> > 
> > This query won't work, even if i escape the : with \
> > 
> > Any ideas ?
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)
#### Post date: [September 23, 2013, 9:25pm UTC](https://discuss.elastic.co/t/search-for-uris-which-match-a-server/13701/4 "2013-09-23T21:25:18Z")

</div>

Hi,  
did you make sure you never get back errors from elasticsearch? I just  
tried the following, without even submitting a custom mapping (using the  
default one) and it worked fine:

curl -XPUT localhost:9200/test/test/1 -d '{  
"uri":"[http://abc.xyz/abc](http://abc.xyz/abc)"  
}  
'

curl -XPOST localhost:9200/test/test/\_search -d '{  
"query": {  
"constant\_score": {  
"filter": {  
"prefix": {  
"uri": "http"  
}  
}  
}  
}  
}  
'

I had to slightly modify your curl requests though. The documents contained  
unquoted field names and the constant score query contained a filter array,  
which is not supposed to be an array but a single object.  
The above query returns the document that I previously indexed.

Cheers  
Luca

On Monday, September 23, 2013 3:43:55 PM UTC+2, Andreas Jaekle wrote:

> hi,  
> i tried it, but it is not working.  
> this is my test script:
> 
> IP=127.0.0.1
> 
> curl -XPUT "$IP:9200/test" -d '{  
> "mappings": {  
> "sample":{  
> "properties" : {  
> "uri" : {  
> "type": "string",  
> "index": "not\_analyzed"  
> }  
> }  
> }  
> }  
> }'
> 
> echo ""  
> echo "------------------------------------------------"  
> curl -XPOST "http://:9200$IP/test/test/1" --data  
> '{uri:"[http://abc.def/abc",value:"abc](http://abc.def/abc%22,value:%22abc)"}'  
> echo ""  
> curl -XPOST "http://:9200$IP/test/test/2" --data  
> '{uri:"[http://abc.xyz/abc",value:"def](http://abc.xyz/abc%22,value:%22def)"}'  
> echo ""  
> curl -XPOST "http://:9200$IP/test/test/3" --data  
> '{uri:"[http://abc.ijk/abc",value:"ijk](http://abc.ijk/abc%22,value:%22ijk)"}'
> 
> sleep 2  
> echo ""  
> echo "------------------------------------------------ simple prefix  
> search:"  
> curl "http://:9200$IP/test/\_search?pretty=true" --data  
> '{"query":{"constant\_score":{"filter":[{"prefix":{"uri":"http"}}]}},"from":0,"size":10,"sort":,"facets":{}}'
> 
> echo ""  
> echo "------------------------------------------------ search (not  
> working):"  
> curl "http://:9200$IP/test/\_search?pretty=true" --data  
> '{"query":{"constant\_score":{"filter":[{"prefix":{"uri":"http:"}}]}},"from":0,"size":10,"sort":,"facets":{}}'
> 
> echo ""  
> echo "------------------------------------------------ all"  
> curl "http://:9200$IP/test/\_search?pretty=true"  
> echo ""  
> echo "------------------------------------------------ mapping"  
> curl "http://:9200$IP/\_mapping?pretty=true"
> 
> Am 20.09.2013 18:24, schrieb Jun Ohtani:
> 
> > Hi Andreas,
> > 
> > Maybe, you use default setting, that analyzer is standard analyzer.  
> > ':' is not indexed, if you use standard analyzer
> > 
> > Do you run following command?  
> > It's response how to analyze uri field in Elasticsearch.
> > 
> > curl -XPOST '  
> > [http://localhost:9200/url\_test/\_analyze?pretty=true&field=uri](http://localhost:9200/url_test/_analyze?pretty=true&field=uri)' --data '  
> > [http://abc.xyz/abc](http://abc.xyz/abc)'
> > 
> > Probably, you get the following response.
> > 
> > {  
> > "tokens" : [ {  
> > "token" : "http",  
> > "start\_offset" : 0,  
> > "end\_offset" : 4,  
> > "type" : "",  
> > "position" : 1  
> > }, {  
> > "token" : "abc.xyz",  
> > "start\_offset" : 7,  
> > "end\_offset" : 14,  
> > "type" : "",  
> > "position" : 2  
> > }, {  
> > "token" : "abc",  
> > "start\_offset" : 15,  
> > "end\_offset" : 18,  
> > "type" : "",  
> > "position" : 3  
> > } ]  
> > }
> > 
> > If you do not want analyze uri field, you use following mappings to  
> > create index.
> > 
> > curl -XPUT 'localhost:9200/url\_test' -d '{  
> > "mappings": {  
> > "sample":{  
> > "properties" : {  
> > "uri" : {  
> > "type": "string",  
> > "index": "not\_analyzed"  
> > }  
> > }  
> > }  
> > }  
> > }'
> > 
> > Regards
> > 
> > * * *
> > 
> > Jun Ohtani  
> > [joh...@gmail.com](mailto:joh...@gmail.com) \<javascript:\>  
> > blog(japanese) : [http://blog.johtani.info](http://blog.johtani.info)  
> > twitter : [http://twitter.com/johtani](http://twitter.com/johtani)
> > 
> > On 2013/09/20, at 19:24, Andreas Jaekle \<[andreas...@gmail.com](mailto:andreas...@gmail.com)\<javascript:\>\>  
> > wrote:
> > 
> > > hi,  
> > > im trying to search for URIs which are on one domain. But the search  
> > > always fails at the ":"  
> > > How can i search for all URIs which start with "[http://abc.xyz/](http://abc.xyz/)"
> > > 
> > > curl -XPOST '[http://localhost:9200/test/test/1](http://localhost:9200/test/test/1)' --data '{uri:"  
> > > [http://abc.def/abc](http://abc.def/abc)"}'
> > > 
> > > curl -XPOST '[http://localhost:9200/test/test/2](http://localhost:9200/test/test/2)' --data '{uri:"  
> > > [http://abc.xyz/abc](http://abc.xyz/abc)"}'
> > > 
> > > curl -XPOST '[http://localhost:9200/test/test/3](http://localhost:9200/test/test/3)' --data '{uri:"  
> > > [http://abc.ijk/abc](http://abc.ijk/abc)"}'
> > > 
> > > curl '[http://localhost:9200/test/\_search?pretty=true](http://localhost:9200/test/_search?pretty=true)' --data  
> > > '{"query":{"constant\_score":{"filter":[{"prefix":{"uri":"http:"}}],"must\_not":,"should":}},"from":0,"size":10,"sort":,"facets":{}}'
> 
> > > This query won't work, even if i escape the : with \
> > > 
> > > Any ideas ?
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Andreas\_Jaekle](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andreas_jaekle/32/1548_2.png) [@Andreas\_Jaekle](https://discuss.elastic.co/u/Andreas_Jaekle)
#### Post date: [September 23, 2013, 9:29pm UTC](https://discuss.elastic.co/t/search-for-uris-which-match-a-server/13701/5 "2013-09-23T21:29:24Z")

</div>

hi,  
yes, with only "http" it works fine but with "http\*:\*" it fails  
in the end i want to search for uri parts, but it don't accept the : in uris

Am 23.09.2013 23:25, schrieb Luca Cavanna:

> Hi,  
> did you make sure you never get back errors from elasticsearch? I just  
> tried the following, without even submitting a custom mapping (using  
> the default one) and it worked fine:
> 
> curl -XPUT localhost:9200/test/test/1 -d '{  
> "uri":"[http://abc.xyz/abc](http://abc.xyz/abc)"  
> }  
> '
> 
> curl -XPOST localhost:9200/test/test/\_search -d '{  
> "query": {  
> "constant\_score": {  
> "filter": {  
> "prefix": {  
> "uri": "http"  
> }  
> }  
> }  
> }  
> }  
> '
> 
> I had to slightly modify your curl requests though. The documents  
> contained unquoted field names and the constant score query contained  
> a filter array, which is not supposed to be an array but a single object.  
> The above query returns the document that I previously indexed.
> 
> Cheers  
> Luca
> 
> On Monday, September 23, 2013 3:43:55 PM UTC+2, Andreas Jaekle wrote:
> 
> ```
> hi,
> i tried it, but it is not working.
> this is my test script:
> 
> IP=127.0.0.1
> 
> curl -XPUT "$IP:9200/test" -d '{
> "mappings": {
> "sample":{
> "properties" : {
> "uri" : {
> "type": "string",
> "index": "not_analyzed"
> }
> }
> }
> }
> }'
> 
> echo ""
> echo "------------------------------------------------"
> curl -XPOST "http://$IP:9200/test/test/1" --data
> '{uri:"http://abc.def/abc",value:"abc"}'
> echo ""
> curl -XPOST "http://$IP:9200/test/test/2" --data
> '{uri:"http://abc.xyz/abc",value:"def"}'
> echo ""
> curl -XPOST "http://$IP:9200/test/test/3" --data
> '{uri:"http://abc.ijk/abc",value:"ijk"}'
> 
> sleep 2
> echo ""
> echo "------------------------------------------------ simple prefix
> search:"
> curl "http://$IP:9200/test/_search?pretty=true" --data
> '{"query":{"constant_score":{"filter":[{"prefix":{"uri":"http"}}]}},"from":0,"size":10,"sort":[],"facets":{}}'
> 
> echo ""
> echo "------------------------------------------------ search (not
> working):"
> curl "http://$IP:9200/test/_search?pretty=true" --data
> '{"query":{"constant_score":{"filter":[{"prefix":{"uri":"http:"}}]}},"from":0,"size":10,"sort":[],"facets":{}}'
> 
> echo ""
> echo "------------------------------------------------ all"
> curl "http://$IP:9200/test/_search?pretty=true"
> echo ""
> echo "------------------------------------------------ mapping"
> curl "http://$IP:9200/_mapping?pretty=true"
> 
> Am 20.09.2013 18:24, schrieb Jun Ohtani:
> > Hi Andreas,
> >
> > Maybe, you use default setting, that analyzer is standard analyzer.
> > ':' is not indexed, if you use standard analyzer
> >
> > Do you run following command?
> > It's response how to analyze uri field in ElasticSearch.
> >
> > curl -XPOST
> 'http://localhost:9200/url_test/_analyze?pretty=true&field=uri
> <http://localhost:9200/url_test/_analyze?pretty=true&field=uri>'
> --data 'http://abc.xyz/abc'
> >
> > Probably, you get the following response.
> >
> > {
> > "tokens" : [ {
> > "token" : "http",
> > "start_offset" : 0,
> > "end_offset" : 4,
> > "type" : "<ALPHANUM>",
> > "position" : 1
> > }, {
> > "token" : "abc.xyz",
> > "start_offset" : 7,
> > "end_offset" : 14,
> > "type" : "<ALPHANUM>",
> > "position" : 2
> > }, {
> > "token" : "abc",
> > "start_offset" : 15,
> > "end_offset" : 18,
> > "type" : "<ALPHANUM>",
> > "position" : 3
> > } ]
> > }
> >
> > If you do not want analyze uri field, you use following mappings
> to create index.
> >
> > curl -XPUT 'localhost:9200/url_test' -d '{
> > "mappings": {
> > "sample":{
> > "properties" : {
> > "uri" : {
> > "type": "string",
> > "index": "not_analyzed"
> > }
> > }
> > }
> > }
> > }'
> >
> >
> > Regards
> >
> > ------------
> > Jun Ohtani
> > joh...@gmail.com <javascript:>
> > blog(japanese) : http://blog.johtani.info
> > twitter : http://twitter.com/johtani
> >
> >
> >
> >
> > On 2013/09/20, at 19:24, Andreas Jaekle <andreas...@gmail.com
> <javascript:>> wrote:
> >
> >> hi,
> >> im trying to search for URIs which are on one domain. But the
> search always fails at the ":"
> >> How can i search for all URIs which start with "http://abc.xyz/"
> >>
> >> curl -XPOST 'http://localhost:9200/test/test/1
> <http://localhost:9200/test/test/1>' --data
> '{uri:"http://abc.def/abc"}'
> >>
> >> curl -XPOST 'http://localhost:9200/test/test/2
> <http://localhost:9200/test/test/2>' --data
> '{uri:"http://abc.xyz/abc"}'
> >>
> >> curl -XPOST 'http://localhost:9200/test/test/3
> <http://localhost:9200/test/test/3>' --data
> '{uri:"http://abc.ijk/abc"}'
> >>
> >> curl 'http://localhost:9200/test/_search?pretty=true
> <http://localhost:9200/test/_search?pretty=true>' --data
> '{"query":{"constant_score":{"filter":[{"prefix":{"uri":"http:"}}],"must_not":[],"should":[]}},"from":0,"size":10,"sort":[],"facets":{}}'
> 
> >>
> >> This query won't work, even if i escape the : with \
> >>
> >> Any ideas ?
> >>
> >> --
> >> You received this message because you are subscribed to the
> Google Groups "elasticsearch" group.
> >> To unsubscribe from this group and stop receiving emails from
> it, send an email to elasticsearc...@googlegroups.com <javascript:>.
> >> For more options, visit
> https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
> 
> ```
> 
> --  
> You received this message because you are subscribed to the Google  
> Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send  
> an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)
#### Post date: [September 23, 2013, 10:16pm UTC](https://discuss.elastic.co/t/search-for-uris-which-match-a-server/13701/6 "2013-09-23T22:16:24Z")

</div>

Hey,  
sorry my bad I had missed that bit. You do need to configure the field as  
not\_analyzed, otherwise the ":" would get removed and given that a prefix  
query is not analyzed, you would be querying for "http:" against an index  
that only contains "http".

The mistake is that you submit the mapping for the type "sample" but the  
document is under the test type. You should either index document under  
test/sample, or change the root object in your mapping to "test" instead of  
sample.

Cheers  
Luca

On Mon, Sep 23, 2013 at 11:29 PM, Andreas J [andreas.jaekle@gmail.com](mailto:andreas.jaekle@gmail.com)wrote:

> hi,  
> yes, with only "http" it works fine but with "http\*:\*" it fails  
> in the end i want to search for uri parts, but it don't accept the : in  
> uris
> 
> Am 23.09.2013 23:25, schrieb Luca Cavanna:
> 
> Hi,  
> did you make sure you never get back errors from elasticsearch? I just  
> tried the following, without even submitting a custom mapping (using the  
> default one) and it worked fine:
> 
> curl -XPUT localhost:9200/test/test/1 -d '{  
> "uri":"[http://abc.xyz/abc](http://abc.xyz/abc)" [http://abc.xyz/abc](http://abc.xyz/abc)  
> }  
> '
> 
> curl -XPOST localhost:9200/test/test/\_search -d '{  
> "query": {  
> "constant\_score": {  
> "filter": {  
> "prefix": {  
> "uri": "http"  
> }  
> }  
> }  
> }  
> }  
> '
> 
> I had to slightly modify your curl requests though. The documents  
> contained unquoted field names and the constant score query contained a  
> filter array, which is not supposed to be an array but a single object.  
> The above query returns the document that I previously indexed.
> 
> Cheers  
> Luca
> 
> On Monday, September 23, 2013 3:43:55 PM UTC+2, Andreas Jaekle wrote:
> 
> > hi,  
> > i tried it, but it is not working.  
> > this is my test script:
> > 
> > IP=127.0.0.1
> > 
> > curl -XPUT "$IP:9200/test" -d '{  
> > "mappings": {  
> > "sample":{  
> > "properties" : {  
> > "uri" : {  
> > "type": "string",  
> > "index": "not\_analyzed"  
> > }  
> > }  
> > }  
> > }  
> > }'
> > 
> > echo ""  
> > echo "-----------------------------\*\*-------------------"  
> > curl -XPOST "http://:9200$IP/test/test/1" http://:9200$IP/test/test/1 --data  
> > '{uri:"[http://abc.def/abc",\*\*value:"abc](http://abc.def/abc%22,**value:%22abc)"}'  
> > echo ""  
> > curl -XPOST "http://:9200$IP/test/test/2" http://:9200$IP/test/test/2 --data  
> > '{uri:"[http://abc.xyz/abc",\*\*value:"def](http://abc.xyz/abc%22,**value:%22def)"}'  
> > echo ""  
> > curl -XPOST "http://:9200$IP/test/test/3" http://:9200$IP/test/test/3 --data  
> > '{uri:"[http://abc.ijk/abc",\*\*value:"ijk](http://abc.ijk/abc%22,**value:%22ijk)"}'
> > 
> > sleep 2  
> > echo ""  
> > echo "-----------------------------**------------------- simple prefix  
> > search:"  
> > curl "http://:9200$IP/test/\_search?\*\*pretty=true" --data  
> > '{"query":{"constant\_score":{"filter":[{"prefix":{"uri":"  
> > http"}}]}},"from":0,"size":10,**"sort":,"facets":{}}'
> > 
> > echo ""  
> > echo "-----------------------------\*\*------------------- search (not  
> > working):"  
> > curl "http://:9200$IP/test/\_search?\*\*pretty=true" --data  
> > '{"query":{"constant\_score":{"**filter":[{"prefix":{"uri":"**  
> > http:"}}]}},"from":0,"size":\*\*10,"sort":,"facets":{}}'
> > 
> > echo ""  
> > echo "-----------------------------**------------------- all"  
> > curl "http://:9200$IP/test/\_search?\*\*pretty=true"  
> > echo ""  
> > echo "-----------------------------**------------------- mapping"  
> > curl "http://:9200$IP/\_mapping?\*\*pretty=true"
> > 
> > Am 20.09.2013 18:24, schrieb Jun Ohtani:
> > 
> > > Hi Andreas,
> > > 
> > > Maybe, you use default setting, that analyzer is standard analyzer.  
> > > ':' is not indexed, if you use standard analyzer
> > > 
> > > Do you run following command?  
> > > It's response how to analyze uri field in Elasticsearch.
> > > 
> > > curl -XPOST '[http://localhost:9200/url\_\*\*test/\_analyze?pretty=true&](http://localhost:9200/url_**test/_analyze?pretty=true&)\*\*  
> > > field=uri [http://localhost:9200/url\_test/\_analyze?pretty=true&field=uri](http://localhost:9200/url_test/_analyze?pretty=true&field=uri)'  
> > > --data '[http://abc.xyz/abc](http://abc.xyz/abc)'
> > > 
> > > Probably, you get the following response.
> > > 
> > > {  
> > > "tokens" : [ {  
> > > "token" : "http",  
> > > "start\_offset" : 0,  
> > > "end\_offset" : 4,  
> > > "type" : "",  
> > > "position" : 1  
> > > }, {  
> > > "token" : "abc.xyz",  
> > > "start\_offset" : 7,  
> > > "end\_offset" : 14,  
> > > "type" : "",  
> > > "position" : 2  
> > > }, {  
> > > "token" : "abc",  
> > > "start\_offset" : 15,  
> > > "end\_offset" : 18,  
> > > "type" : "",  
> > > "position" : 3  
> > > } ]  
> > > }
> > > 
> > > If you do not want analyze uri field, you use following mappings to  
> > > create index.
> > > 
> > > curl -XPUT 'localhost:9200/url\_test' -d '{  
> > > "mappings": {  
> > > "sample":{  
> > > "properties" : {  
> > > "uri" : {  
> > > "type": "string",  
> > > "index": "not\_analyzed"  
> > > }  
> > > }  
> > > }  
> > > }  
> > > }'
> > > 
> > > Regards
> > > 
> > > * * *
> > > 
> > > Jun Ohtani  
> > > [joh...@gmail.com](mailto:joh...@gmail.com)  
> > > blog(japanese) : [http://blog.johtani.info](http://blog.johtani.info)  
> > > twitter : [http://twitter.com/johtani](http://twitter.com/johtani)
> > > 
> > > On 2013/09/20, at 19:24, Andreas Jaekle [andreas...@gmail.com](mailto:andreas...@gmail.com) wrote:
> > > 
> > > > hi,  
> > > > im trying to search for URIs which are on one domain. But the search  
> > > > always fails at the ":"  
> > > > How can i search for all URIs which start with "[http://abc.xyz/](http://abc.xyz/)"
> > > > 
> > > > curl -XPOST '[http://localhost:9200/test/\*\*test/1](http://localhost:9200/test/**test/1)[http://localhost:9200/test/test/1](http://localhost:9200/test/test/1)'  
> > > > --data '{uri:"[http://abc.def/abc](http://abc.def/abc)"}'
> > > > 
> > > > curl -XPOST '[http://localhost:9200/test/\*\*test/2](http://localhost:9200/test/**test/2)[http://localhost:9200/test/test/2](http://localhost:9200/test/test/2)'  
> > > > --data '{uri:"[http://abc.xyz/abc](http://abc.xyz/abc)"}'
> > > > 
> > > > curl -XPOST '[http://localhost:9200/test/\*\*test/3](http://localhost:9200/test/**test/3)[http://localhost:9200/test/test/3](http://localhost:9200/test/test/3)'  
> > > > --data '{uri:"[http://abc.ijk/abc](http://abc.ijk/abc)"}'
> > > > 
> > > > curl '[http://localhost:9200/test/\_\*\*search?pretty=true](http://localhost:9200/test/_**search?pretty=true)[http://localhost:9200/test/\_search?pretty=true](http://localhost:9200/test/_search?pretty=true)'  
> > > > --data '{"query":{"constant\_score":{"**filter":[{"prefix":{"uri":"**  
> > > > http:"}}],"must\_not":,"\*\*should":}},"from":0,"size":\*\*10,"sort":,"facets":{}}'
> > 
> > > > This query won't work, even if i escape the : with \
> > > > 
> > > > Any ideas ?
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).  
> > > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/VyrBzf8As44/unsubscribe](https://groups.google.com/d/topic/elasticsearch/VyrBzf8As44/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:15am UTC](https://discuss.elastic.co/t/search-for-uris-which-match-a-server/13701/7 "2017-07-06T02:15:03Z")

</div>


