Giter Club home page Giter Club logo

Comments (4)

bitemyapp avatar bitemyapp commented on June 1, 2024

@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.

astro avatar astro commented on June 1, 2024
{-# LANGUAGE OverloadedStrings #-}

DocID "http://example.com/feed.xml http://example.com/post/1"

from bloodhound.

bitemyapp avatar bitemyapp commented on June 1, 2024

@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.

MaxDaten avatar MaxDaten commented on June 1, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.