Git Product home page Git Product logo

Comments (19)

sksamuel avatar sksamuel commented on June 15, 2024

You're right it's missing. Let's add it. Do you want to take it up or do you want me to do it ?

from elastic4s.

bfritz avatar bfritz commented on June 15, 2024

Either way. If I take a shot, it would be helpful if you could point me in the right direction first. I'm not a complete Scala newbie, but not too far from it. It'd probably be late this week before I have a chance to work on it.

from elastic4s.

sksamuel avatar sksamuel commented on June 15, 2024

Ok I'll do some stuff and get your feedback.

from elastic4s.

bfritz avatar bfritz commented on June 15, 2024

Awesome. Thank you!

from elastic4s.

guersam avatar guersam commented on June 15, 2024

Integration with third-party JSON libraries such as json4s, play-json, spray-json or etc. will allow indexing/querying arbitrary case classes as well as common collections. Here's an example from redisreact.

from elastic4s.

guersam avatar guersam commented on June 15, 2024

But in our case something more is needed to match them to ES schema...

from elastic4s.

sksamuel avatar sksamuel commented on June 15, 2024

I think he means creating a mapping. I think using dot notation would suffice?

from elastic4s.

guersam avatar guersam commented on June 15, 2024

Oops... my bad, had too little sleep at that time.

from elastic4s.

fehmicansaglam avatar fehmicansaglam commented on June 15, 2024

Instead of using dot notation, ability to use nested mappings makes more sense to me.

client.execute { 
    create index "places" mappings (
        "cities" as (      
            field("id") typed IntegerType,
            field("name") boost 4,
            field("content") analyzer StopAnalyzer
            nested("stats") as (
                field("population") typed IntegerType,
                field("elavation") typed IntegerType
            )
        )
     )
}

from elastic4s.

sksamuel avatar sksamuel commented on June 15, 2024

Right, might be nicer though if the word field could be retained, eg

client.execute { 
    create index "places" mappings (
        "cities" as (      
            field("id") typed IntegerType,
            field("name") boost 4,
            field("content") analyzer StopAnalyzer
            field("stats") as ( 
                field("population") typed IntegerType,
                field("elavation") typed IntegerType
            )
        )
     )
}

from elastic4s.

sksamuel avatar sksamuel commented on June 15, 2024

Or actually, field could be updated to accept a new "mapping" defintion, which can be recursive, so you could do this

client.execute { 
    create index "places" mappings (
        "cities" as (      
            field("id") typed IntegerType,
            field("name") boost 4,
            field("content") analyzer StopAnalyzer
            "stats" as ( 
                field("population") typed IntegerType,
                field("elavation") typed IntegerType
            )
        )
     )
}

Ie the "stats" part is actually an instance of the same object as "cities" is. Just forms a tree of definitions.

from elastic4s.

fehmicansaglam avatar fehmicansaglam commented on June 15, 2024

Yep, I was actually thinking of the same in terms of implementation. And your syntax looks pretty awesome.

from elastic4s.

bfritz avatar bfritz commented on June 15, 2024

@sksamuel Looks good to me as well.

from elastic4s.

sksamuel avatar sksamuel commented on June 15, 2024

Great, we all seem happy :)

from elastic4s.

ornicar avatar ornicar commented on June 15, 2024

Hi, I'm giving elastic4s a try for the next version of http://scalex.org and so far it looks promising. Nested mapping, indeed, would be a must. Cheers!

from elastic4s.

sksamuel avatar sksamuel commented on June 15, 2024

It's in progress ATM :)

from elastic4s.

sksamuel avatar sksamuel commented on June 15, 2024

There was a little issue with implicits. This is what I ended up with :

create.index("users").shards(2).mappings(
      "tweets" as(
        id typed StringType analyzer KeywordAnalyzer,
        "name" typed StringType analyzer KeywordAnalyzer,
        "locations" typed GeoPointType analyzer SimpleAnalyzer boost 4,
        "date" typed DateType,
        "content" typed StringType,
        "user" nested(
          "name" typed StringType,
          "email" typed StringType,
          "last" nested {
            "lastLogin" typed DateType
          }
          )
        ) size true numericDetection true boostNullValue 1.2 boost "myboost"
    )

This is currently in master.

from elastic4s.

ornicar avatar ornicar commented on June 15, 2024

It looks wonderful. Thank you.

from elastic4s.

sksamuel avatar sksamuel commented on June 15, 2024

Please don't put this onto an related, closed, ticket. Create a new ticket if there is a bug, or even better, ask a question at stack overflow using the tag elastic4s and I'll answer it there (and add more details, as its probably what you doing around the request that is the error).

from elastic4s.

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.