-
Notifications
You must be signed in to change notification settings - Fork 1
/
README
106 lines (87 loc) · 2.54 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
data-model
==========
Automagically generated test data
This library allows using expanded definition of generated data.
Using JSON format the following information could be defined:
* field name
* type (currently supported: identifier, integer, long, date, string, text, array, object, enum)
* probability - number from 0 to 100, indicating the probability that the
defined field will be present in the generated document (100
means that the field will be present in all the documents,
50 means that about 50% of the documents will contain given field)
* size (for arrays)
Example of input file:
{
"data" : {
"id" : {
"type" : "identifier"
},
"tags" : {
"type" : "array",
"subtype" : {
"type": "integer"
},
"size" : 10
},
"position" : {
"type" : "object",
"fields" : {
"lon" : {
"type" : "long"
},
"lat" : {
"type" : "long"
}
},
"probability" : 50
},
"created" : {
"type" : "date"
},
"name" : {
"type" : "string",
"probability" : 30
},
"status" : {
"type" : "enum",
"available" : ["OPEN", "WAITING", "RUN", "CLOSED"]
}
}
}
Usage:
DataModel model = DataModel.builder().fromJson(DataModelTest.class.getResourceAsStream("/input.json"));
Output depends on producer class used. For example:
new SolrDataModelProducer().convert(model.getValue());
generates:
<doc>
<field name="id">30</field>
<field name="tags">1061831906</field>
<field name="tags">1823041322</field>
<field name="tags">1043347384</field>
<field name="tags">1435798929</field>
<field name="tags">1863886272</field>
<field name="tags">614448648</field>
<field name="tags">899164045</field>
<field name="tags">293936725</field>
<field name="tags">1762090246</field>
<field name="tags">1009759002</field>
<field name="position.lon">-3400858544594038103</field>
<field name="position.lat">-3581634897016771756</field>
<field name="created">2011-05-15T20:57:28</field>
</doc>
For JsonDataModelProducer:
new JsonDataModelProducer().convert(model.getValue());
output can be:
{
"id":"3",
"tags":[1102324772,1639875632,941233980,187315297,99270113,2044803615,1811470888,1093630565,2071000800,2129652106],
"created":1015062520000
}
DataModel is released under Apache License, Version 2.0 and available in sonatype repository:
https://oss.sonatype.org/content/groups/public/
You can use it in maven with:
<dependency>
<groupId>pl.solr.datamodel</groupId>
<artifactId>datamodel</artifactId>
<version>0.0.3</version>
</dependency>