Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit028d69c

Browse files
committed
support excludeTags
1 parentc94a39e commit028d69c

File tree

7 files changed

+108
-37
lines changed

7 files changed

+108
-37
lines changed

‎src/main/java/com/indoqa/solr/facet/api/AbstractFacet.java‎

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public abstract class AbstractFacet implements Facet {
3030

3131
privateStringname;
3232
privateStringtype;
33+
privateDomaindomain;
3334

3435
protectedList<Facet>subFacets =newArrayList<>();
3536

@@ -38,6 +39,42 @@ public AbstractFacet(String type, String name) {
3839
this.name =name;
3940
}
4041

42+
protectedstaticvoidwriteArray(JSONWriterjsonWriter,StringfieldName,Object[]array) {
43+
jsonWriter.write(fieldName);
44+
jsonWriter.writeNameSeparator();
45+
46+
if (array.length ==1) {
47+
jsonWriter.write(array[0]);
48+
}else {
49+
jsonWriter.startArray();
50+
jsonWriter.write(array);
51+
jsonWriter.endArray();
52+
}
53+
}
54+
55+
protectedstaticvoidwriteBooleanField(JSONWriterjsonWriter,StringfieldName,booleanvalue) {
56+
jsonWriter.write(fieldName);
57+
jsonWriter.writeNameSeparator();
58+
jsonWriter.write(value);
59+
}
60+
61+
protectedstaticvoidwriteNumberField(JSONWriterjsonWriter,StringfieldName,Numbervalue) {
62+
jsonWriter.write(fieldName);
63+
jsonWriter.writeNameSeparator();
64+
jsonWriter.write(value);
65+
}
66+
67+
protectedstaticvoidwriteStringField(JSONWriterjsonWriter,StringfieldName,Stringvalue) {
68+
jsonWriter.write(fieldName);
69+
jsonWriter.writeNameSeparator();
70+
jsonWriter.write(value);
71+
}
72+
73+
protectedstaticvoidwriteValueSeparator(JSONWriterjsonWriter) {
74+
jsonWriter.writeValueSeparator();
75+
jsonWriter.indent();
76+
}
77+
4178
@Override
4279
publicFacetaddSubFacet(Facetfacet) {
4380
this.subFacets.add(facet);
@@ -56,15 +93,19 @@ public boolean hasSubFacets() {
5693
return !this.subFacets.isEmpty();
5794
}
5895

96+
publicvoidsetDomain(Domaindomain) {
97+
this.domain =domain;
98+
}
99+
59100
@Override
60101
publicvoidstreamToJson(JSONWriterjsonWriter) {
61102
jsonWriter.write(this.name);
62103
jsonWriter.writeNameSeparator();
63104

64105
jsonWriter.startObject();
65106
jsonWriter.indent();
66-
this.writeStringField(jsonWriter,FIELD_TYPE,this.type);
67-
this.writeValueSeparator(jsonWriter);
107+
writeStringField(jsonWriter,FIELD_TYPE,this.type);
108+
writeValueSeparator(jsonWriter);
68109
this.writeFacetConfiguration(jsonWriter);
69110
this.writeSubFacets(jsonWriter);
70111
jsonWriter.indent();
@@ -88,42 +129,29 @@ public String toJsonString() {
88129
returncharArr.toString();
89130
}
90131

91-
protectedvoidwriteBooleanField(JSONWriterjsonWriter,StringfieldName,booleanvalue) {
92-
jsonWriter.write(fieldName);
93-
jsonWriter.writeNameSeparator();
94-
jsonWriter.write(value);
132+
protectedvoidwriteFacetConfiguration(JSONWriterjsonWriter) {
133+
if (this.domain !=null) {
134+
this.domain.streamToJson(jsonWriter);
135+
writeValueSeparator(jsonWriter);
136+
}
95137
}
96138

97-
protectedabstractvoidwriteFacetConfiguration(JSONWriterjsonWriter);
98-
99139
protectedvoidwriteFacets(JSONWriterjsonWriter,List<Facet>facets) {
100140
for (ListIterator<Facet>it =facets.listIterator();it.hasNext();) {
101141
it.next().streamToJson(jsonWriter);
102142

103143
if (it.hasNext()) {
104-
this.writeValueSeparator(jsonWriter);
144+
writeValueSeparator(jsonWriter);
105145
}
106146
}
107147
}
108148

109-
protectedvoidwriteNumberField(JSONWriterjsonWriter,StringfieldName,Numbervalue) {
110-
jsonWriter.write(fieldName);
111-
jsonWriter.writeNameSeparator();
112-
jsonWriter.write(value);
113-
}
114-
115-
protectedvoidwriteStringField(JSONWriterjsonWriter,StringfieldName,Stringvalue) {
116-
jsonWriter.write(fieldName);
117-
jsonWriter.writeNameSeparator();
118-
jsonWriter.write(value);
119-
}
120-
121149
protectedvoidwriteSubFacets(JSONWriterjsonWriter) {
122150
if (this.subFacets.isEmpty()) {
123151
return;
124152
}
125153

126-
this.writeValueSeparator(jsonWriter);
154+
writeValueSeparator(jsonWriter);
127155
jsonWriter.write(FIELD_FACET);
128156
jsonWriter.writeNameSeparator();
129157

@@ -133,9 +161,4 @@ protected void writeSubFacets(JSONWriter jsonWriter) {
133161
jsonWriter.indent();
134162
jsonWriter.endObject();
135163
}
136-
137-
protectedvoidwriteValueSeparator(JSONWriterjsonWriter) {
138-
jsonWriter.writeValueSeparator();
139-
jsonWriter.indent();
140-
}
141164
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Licensed to the Indoqa Software Design und Beratung GmbH (Indoqa) under
3+
* one or more contributor license agreements. See the NOTICE file distributed
4+
* with this work for additional information regarding copyright ownership.
5+
* Indoqa licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
packagecom.indoqa.solr.facet.api;
18+
19+
importorg.noggit.JSONWriter;
20+
21+
publicclassDomainimplementsJsonStreamer {
22+
23+
privatestaticfinalStringFIELD_DOMAIN ="domain";
24+
privatestaticfinalStringFIELD_EXCLUDE_TAGS ="excludeTags";
25+
26+
privateString[]excludeTags;
27+
28+
publicstaticDomainwithExcludeTags(String...excludeTags) {
29+
Domainresult =newDomain();
30+
result.setExcludeTags(excludeTags);
31+
returnresult;
32+
}
33+
34+
publicString[]getExcludeTags() {
35+
returnthis.excludeTags;
36+
}
37+
38+
publicvoidsetExcludeTags(String[]excludeTags) {
39+
this.excludeTags =excludeTags;
40+
}
41+
42+
@Override
43+
publicvoidstreamToJson(JSONWriterjsonWriter) {
44+
jsonWriter.write(FIELD_DOMAIN);
45+
jsonWriter.writeNameSeparator();
46+
jsonWriter.startObject();
47+
jsonWriter.indent();
48+
AbstractFacet.writeArray(jsonWriter,FIELD_EXCLUDE_TAGS,this.excludeTags);
49+
jsonWriter.indent();
50+
jsonWriter.endObject();
51+
}
52+
}

‎src/main/java/com/indoqa/solr/facet/api/FacetList.java‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,4 @@ public void streamToJson(JSONWriter jsonWriter) {
4040

4141
this.writeFacets(jsonWriter,this.subFacets);
4242
}
43-
44-
@Override
45-
protectedvoidwriteFacetConfiguration(JSONWriterjsonWriter) {
46-
// nothing to do
47-
}
4843
}

‎src/main/java/com/indoqa/solr/facet/api/QueryFacet.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public QueryFacet(String name, CharSequence query) {
3333

3434
@Override
3535
protectedvoidwriteFacetConfiguration(JSONWriterjsonWriter) {
36+
super.writeFacetConfiguration(jsonWriter);
37+
3638
this.writeStringField(jsonWriter,PARAM_Q,this.query);
3739
}
3840
}

‎src/main/java/com/indoqa/solr/facet/api/RangeFacet.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public RangeFacet(String name, String field, Date start, Date end, GapUnit gapUn
4848

4949
@Override
5050
protectedvoidwriteFacetConfiguration(JSONWriterjsonWriter) {
51+
super.writeFacetConfiguration(jsonWriter);
52+
5153
this.writeStringField(jsonWriter,PARAM_FIELD,this.field);
5254
this.writeValueSeparator(jsonWriter);
5355
this.writeStringField(jsonWriter,PARAM_START,this.toString(this.start));

‎src/main/java/com/indoqa/solr/facet/api/StatisticFacet.java‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,4 @@ public void streamToJson(JSONWriter jsonWriter) {
3333
jsonWriter.writeNameSeparator();
3434
jsonWriter.writeString(this.function);
3535
}
36-
37-
@Override
38-
protectedvoidwriteFacetConfiguration(JSONWriterjsonWriter) {
39-
// nothing to do
40-
}
4136
}

‎src/main/java/com/indoqa/solr/facet/api/TermsFacet.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ public void setSort(String sort) {
8383

8484
@Override
8585
protectedvoidwriteFacetConfiguration(JSONWriterjsonWriter) {
86+
super.writeFacetConfiguration(jsonWriter);
87+
8688
this.writeStringField(jsonWriter,PARAM_FIELD,this.field);
8789

8890
if (this.sort !=null) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp