Comments (4)
@astro usually what I do is provide the nice function under a normal name, then a more "raw" one with a prime tick after the name. Like: func
vs. func'
Could you provide an example of such an ID so I can add it to the test suite?
from bloodhound.
{-# LANGUAGE OverloadedStrings #-}
DocID "http://example.com/feed.xml http://example.com/post/1"
from bloodhound.
@astro alrighty then. I'll see if I can figure out a design that improves safety without being too obnoxious. Thank you for providing the example!
from bloodhound.
Hi, thanks for this library from me, too.
Wrapped in its own type, I expected DocId to safely handle any input. However, indexDocument throws an InvalidUrlException at me because I've got slashes and spaces in there.
Even further on the Elasticsearch side an exception is thrown if i try to escape the DocId
on my own.
Short example
import Database.Bloodhound as E
import Network.URI as URI
import Network.HTTP.Client
import Data.Text as T
server = E.Server "http://192.168.99.100:9200"
libraryIndex = E.IndexName "library"
pageMapping = E.MappingName "page"
docMapping = E.MappingName "document"
runBH' = withBH defaultManagerSettings server
main = do
let doc = E.DocId $ T.pack $ URI.escapeURIString URI.isAllowedInURI "Hello World"
print doc
print =<< runBH' (E.getDocument libraryIndex docMapping doc)
Execution
DocId "Hello%20World"
*** Exception: NoResponseDataReceived
Exception on Elasticsearch
[2015-10-07 08:12:58,245][WARN ][http.netty ] [Uatu] Caught exception while handling client http traffic, closing connection [id: 0xbfe0f66d, /192.168.99.1:53186 => /172.17.0.4:9200]
java.lang.IllegalArgumentException: invalid version format: WORLD HTTP/1.1
at org.elasticsearch.common.netty.handler.codec.http.HttpVersion.<init>(HttpVersion.java:94)
at org.elasticsearch.common.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62)
at org.elasticsearch.common.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75)
at org.elasticsearch.common.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:191)
at org.elasticsearch.common.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:102)
at org.elasticsearch.common.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500)
at org.elasticsearch.common.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:435)
at org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
at org.elasticsearch.common.netty.OpenChannelsHandler.handleUpstream(OpenChannelsHandler.java:74)
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)
at org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:268)
at org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:255)
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)
at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337)
at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
at org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[2015-10-07 08:12:58,250][WARN ][http.netty ] [Uatu] Caught exception while handling client http traffic, closing connection [id: 0xbfe0f66d, /192.168.99.1:53186 :> /172.17.0.4:9200]
java.lang.IllegalArgumentException: empty text
Proposal
Maybe it is possible to avoid URI.ByteString
and just rely on Network.URI
with its escape functions like escapeURIString
from above. Maybe it is even possible to avoid Database.Bloodhound.Client.setURI?
from bloodhound.
Related Issues (20)
- Fuzziness option in MatchQuery HOT 1
- ES 6.4.2 HOT 9
- About Mappings HOT 2
- DocId needs url-encoding for certain operations HOT 7
- Docker Compose support so that full test runs can be spun up
- Re-unifying Bloodhound's implementation HOT 4
- Update to Elastic 7.x (currently 7.4)
- Support count API HOT 1
- Is it possible to use a later version of containers and http-client HOT 2
- Derive Mapping
- Support GHC 8.8 HOT 1
- Update docs at Hackage
- Latest version low upper cap HOT 2
- Build errors with `aeson-2.0.1.0` HOT 1
- In nix stable and unstable, bloodhound is tagged as "broken" HOT 4
- Search parameter `min_score` is not supported
- Library redesign HOT 1
- Not possible to build with http-client >= 0.7 HOT 2
- Add example that deserializes response from ES HOT 2
- `parseEsResponse` not able to parse a "document not found" response HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bloodhound.