[Question] How to represent a list/array of strings in persistence models
See original GitHub issueHi, I need to represent this
PUT my_index/animal/4444
{
"name": "Arara",
"location": "Brasil",
"colors": ["Yellow", "Green", "Blue"]
}
The above works nice and I can perform matches on colors
GET /myindexer/animal/_search
{
"query": {
"bool": {
"must": [
{"match": {
"colors": "Blue"
}}
]
}
}
}
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.5,
"hits": [
{
"_index": "my_index",
"_type": "animal",
"_id": "4444",
"_score": 0.5,
"_source": {
"name": "Arara",
"location": "Brasil",
"colors": [
"Yellow",
"Green",
"Blue"
]
}
}
]
}
}
So to represent the colors list how can I do, is there a List or Array type?
class Animal(DocType):
name = String()
location = String()
colors = List(String()) (????)
Issue Analytics
- State:
- Created 9 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
How to persist a property of type List<String> in JPA?
Command.java. package persistlistofstring; import java.io.Serializable; import java.util.ArrayList; import ...
Read more >Mapping Arrays with Hibernate
Databases support arrays and it's a common Java type. But mapping it with Hibernate is more complex than it might seem.
Read more >String Array in Java with Examples
This code constructs a new ArrayList based on the value returned by Arrays.asList. It will not raise an exception. Converting String Array To...
Read more >Convert an ArrayList of String to a String Array in Java
Method 1: Using ArrayList.get() Method of ArrayList class · Get the ArrayList of Strings. · Find the size of ArrayList using size() method,...
Read more >Hibernate ORM 5.2.18.Final User Guide
In JPA nomenclature, the Session is represented by an EntityManager . ... static final Map<String,String> ABBREVIATIONS = buildAbbreviationMap(); @Override ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@abdelwahebmoalla you don’t need to explicitly define a field as a list, just assign a list of values to it and it will work. if you want the default value of that field to be a list just specify
multi=True
when instantiating the field on yourDocument
subclass:Hope this helps!
I want to implement a switch to make a field a list by default. It will be available for all the fields. It was described in #83