solrium 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +712 -0
- data/README.markdown +51 -0
- data/Rakefile +24 -0
- data/VERSION.yml +4 -0
- data/bin/solr +9 -0
- data/lib/jars/jetty/ant-1.6.5.jar +0 -0
- data/lib/jars/jetty/commons-codec-1.3.jar +0 -0
- data/lib/jars/jetty/commons-fileupload-1.2.jar +0 -0
- data/lib/jars/jetty/jetty-7.0.0.pre5.jar +0 -0
- data/lib/jars/jetty/jetty-util-7.0.0.pre5.jar +0 -0
- data/lib/jars/jetty/jsp-2.1.jar +0 -0
- data/lib/jars/jetty/jsp-api-2.1.jar +0 -0
- data/lib/jars/jetty/servlet-api-3.0.pre4.jar +0 -0
- data/lib/jars/lucene/lucene-analyzers-2.4-dev.jar +0 -0
- data/lib/jars/lucene/lucene-core-2.4-dev.jar +0 -0
- data/lib/jars/lucene/lucene-highlighter-2.4-dev.jar +0 -0
- data/lib/jars/lucene/lucene-memory-2.4-dev.jar +0 -0
- data/lib/jars/lucene/lucene-queries-2.4-dev.jar +0 -0
- data/lib/jars/lucene/lucene-snowball-2.4-dev.jar +0 -0
- data/lib/jars/lucene/lucene-spellchecker-2.4-dev.jar +0 -0
- data/lib/jars/solr/apache-solr-common-1.3.0.jar +0 -0
- data/lib/jars/solr/apache-solr-core-1.3.0.jar +0 -0
- data/lib/jars/solr/commons-io-1.2.jar +0 -0
- data/lib/jars/solr/stax-1.2.0-dev.jar +0 -0
- data/lib/jars/solr/stax-api-1.0.jar +0 -0
- data/lib/jars/solr/stax-utils.jar +0 -0
- data/lib/jars/solr/xpp3-1.1.3.4.O.jar +0 -0
- data/lib/jetty.rb +83 -0
- data/lib/lucene.rb +33 -0
- data/lib/queries.rb +60 -0
- data/lib/remote.rb +22 -0
- data/lib/solr.rb +69 -0
- data/lib/solr_ext.rb +81 -0
- data/lib/webapp/admin/_info.jsp +110 -0
- data/lib/webapp/admin/action.jsp +116 -0
- data/lib/webapp/admin/analysis.jsp +456 -0
- data/lib/webapp/admin/analysis.xsl +179 -0
- data/lib/webapp/admin/distributiondump.jsp +158 -0
- data/lib/webapp/admin/favicon.ico +0 -0
- data/lib/webapp/admin/form.jsp +129 -0
- data/lib/webapp/admin/get-file.jsp +72 -0
- data/lib/webapp/admin/get-properties.jsp +24 -0
- data/lib/webapp/admin/header.jsp +41 -0
- data/lib/webapp/admin/index.jsp +154 -0
- data/lib/webapp/admin/jquery-1.2.3.min.js +32 -0
- data/lib/webapp/admin/logging.jsp +50 -0
- data/lib/webapp/admin/logging.xsl +91 -0
- data/lib/webapp/admin/meta.xsl +34 -0
- data/lib/webapp/admin/ping.jsp +65 -0
- data/lib/webapp/admin/ping.xsl +71 -0
- data/lib/webapp/admin/raw-schema.jsp +38 -0
- data/lib/webapp/admin/registry.jsp +107 -0
- data/lib/webapp/admin/registry.xsl +287 -0
- data/lib/webapp/admin/schema.jsp +661 -0
- data/lib/webapp/admin/solr-admin.css +206 -0
- data/lib/webapp/admin/solr-head.gif +0 -0
- data/lib/webapp/admin/solr-head.png +0 -0
- data/lib/webapp/admin/solr-lowercase.gif +0 -0
- data/lib/webapp/admin/solr-lowercase.png +0 -0
- data/lib/webapp/admin/stats.jsp +94 -0
- data/lib/webapp/admin/stats.xsl +220 -0
- data/lib/webapp/admin/tabular.xsl +141 -0
- data/lib/webapp/admin/threaddump.jsp +110 -0
- data/lib/webapp/admin/threaddump.xsl +103 -0
- data/lib/webapp/favicon.ico +0 -0
- data/lib/webapp/index.jsp +42 -0
- metadata +120 -0
@@ -0,0 +1,661 @@
|
|
1
|
+
<%@ page contentType="text/html; charset=utf-8" pageEncoding="UTF-8"%>
|
2
|
+
<%--
|
3
|
+
Licensed to the Apache Software Foundation (ASF) under one or more
|
4
|
+
contributor license agreements. See the NOTICE file distributed with
|
5
|
+
this work for additional information regarding copyright ownership.
|
6
|
+
The ASF licenses this file to You under the Apache License, Version 2.0
|
7
|
+
(the "License"); you may not use this file except in compliance with
|
8
|
+
the License. You may obtain a copy of the License at
|
9
|
+
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
|
12
|
+
Unless required by applicable law or agreed to in writing, software
|
13
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
See the License for the specific language governing permissions and
|
16
|
+
limitations under the License.
|
17
|
+
--%>
|
18
|
+
|
19
|
+
<%-- $Id: index.jsp 608150 2008-01-02 17:15:30Z ryan $ --%>
|
20
|
+
<%-- $Source: /cvs/main/searching/SolrServer/resources/admin/index.jsp,v $ --%>
|
21
|
+
<%-- $Name: $ --%>
|
22
|
+
|
23
|
+
<script src="jquery-1.2.3.min.js"></script>
|
24
|
+
<script>
|
25
|
+
|
26
|
+
(function($, libName) {
|
27
|
+
var solr = {
|
28
|
+
|
29
|
+
//The default location of the luke handler relative to this page
|
30
|
+
// Can be overridden in the init(url) method
|
31
|
+
pathToLukeHandler: 'luke',
|
32
|
+
|
33
|
+
// Base properties to hold schema information
|
34
|
+
schemaInfo: {},
|
35
|
+
schemaFields: {},
|
36
|
+
schemaDynamicFields: {},
|
37
|
+
schemaTypes: {},
|
38
|
+
schemaFlags: {},
|
39
|
+
|
40
|
+
//The basic function to call to make the initail JSON calls
|
41
|
+
// takes one option parameter, the path to the luke handler
|
42
|
+
// if undefined, it will use the default, 'luke', which means
|
43
|
+
// this is being called from the same relative URL path
|
44
|
+
init: function(pathToLukeHandler) {
|
45
|
+
if (pathToLukeHandler != undefined) {
|
46
|
+
solr.pathToLukeHandler = pathToLukeHandler;
|
47
|
+
}
|
48
|
+
solr.loadSchema(function() {
|
49
|
+
solr.loadFromLukeHandler(function () {
|
50
|
+
solr.createMenu('menu');
|
51
|
+
solr.displaySchemaInfo();
|
52
|
+
});
|
53
|
+
});
|
54
|
+
|
55
|
+
},
|
56
|
+
|
57
|
+
//load the Schema from the LukeRequestHandler
|
58
|
+
// this loads every field, and in each field the copy source/dests and flags
|
59
|
+
// we also load the list of field types, and the list of flags
|
60
|
+
loadSchema: function(func) {
|
61
|
+
$.getJSON(solr.pathToLukeHandler +'?show=schema&wt=json', function(data) {
|
62
|
+
//populate all non field/type/flag data in the info block
|
63
|
+
$.each(data.index, function(i, item) {
|
64
|
+
solr.schemaInfo[i] = item;
|
65
|
+
});
|
66
|
+
|
67
|
+
//LukeRequestHandler places these two attributes outside of the "index" node, but
|
68
|
+
// we want it here so we can more easily display it in the "HOME" block
|
69
|
+
solr.schemaInfo['uniqueKeyField'] = data.schema.uniqueKeyField;
|
70
|
+
solr.schemaInfo['defaultSearchField'] = data.schema.defaultSearchField;
|
71
|
+
//a one-off hack, because the directory string is so long and unbroken
|
72
|
+
// that it can break CSS layouts
|
73
|
+
solr.schemaInfo['directory'] = solr.schemaInfo['directory'].substring(0, solr.schemaInfo['directory'].indexOf('@')+1) + ' ' + solr.schemaInfo['directory'].substring(solr.schemaInfo['directory'].indexOf('@') +1);
|
74
|
+
|
75
|
+
// populate the list of fields
|
76
|
+
$.each(data.schema.fields, function(i,item){
|
77
|
+
solr.schemaFields[i]=item;
|
78
|
+
});
|
79
|
+
// populate the list of field types
|
80
|
+
$.each(data.schema.types, function(type, ft) {
|
81
|
+
solr.schemaTypes[type] = ft;
|
82
|
+
});
|
83
|
+
//populate the list of dynamic fields
|
84
|
+
$.each(data.schema.dynamicFields, function(i, dynField) {
|
85
|
+
solr.schemaDynamicFields[i] = dynField;
|
86
|
+
});
|
87
|
+
//populate the list of flags, so we can convert flags to text in display
|
88
|
+
$.each(data.info.key, function(i, flag) {
|
89
|
+
solr.schemaFlags[i] = flag;
|
90
|
+
});
|
91
|
+
|
92
|
+
//LukeRequestHandler returns copyFields src/dest as the entire toString of the field
|
93
|
+
// we only need the field name, so here we loop through the fields, and replace the full
|
94
|
+
// field definitions with the name in the copySources/copyDests properties
|
95
|
+
$.each(solr.schemaFields, function(i, field) {
|
96
|
+
$.each(['copySources', 'copyDests'], function(i, copyProp) {
|
97
|
+
var newFields = new Array();
|
98
|
+
$.each(field[copyProp], function(i, fullName) {
|
99
|
+
newFields.push(fullName.substring(fullName.lastIndexOf(':')+1, fullName.indexOf('{')));
|
100
|
+
});
|
101
|
+
field[copyProp] = newFields;
|
102
|
+
});
|
103
|
+
|
104
|
+
});
|
105
|
+
//An additional optional callback
|
106
|
+
// used in init to trigger the 2nd call to LukeRequestHandler only
|
107
|
+
// after the first one is finished
|
108
|
+
if ($.isFunction(func)) {
|
109
|
+
func(solr);
|
110
|
+
}
|
111
|
+
});
|
112
|
+
},
|
113
|
+
|
114
|
+
//further populates the loaded schema with information gathered
|
115
|
+
// from the no argument LukeRequestHandler
|
116
|
+
loadFromLukeHandler: function(func) {
|
117
|
+
$.getJSON(solr.pathToLukeHandler+'?wt=json', function(data) {
|
118
|
+
$.each(data.fields, function(i, item) {
|
119
|
+
var field = solr.schemaFields[i];
|
120
|
+
|
121
|
+
//If undefined, then we have a dynamicField which does not show up
|
122
|
+
// in the LukeRequestHandler show=schema variant
|
123
|
+
if (field == undefined) {
|
124
|
+
field = item;
|
125
|
+
//Attach this field to its dynamicField
|
126
|
+
var base = field.dynamicBase;
|
127
|
+
var dynField = solr.schemaDynamicFields[base];
|
128
|
+
|
129
|
+
//Some fields in a multicore setting have no dynamic base, either
|
130
|
+
// the name of the core is a field that has no type or flags
|
131
|
+
if (dynField != undefined) {
|
132
|
+
var synFields = dynField['fields'];
|
133
|
+
if (synFields== undefined) {
|
134
|
+
synFields= new Array();
|
135
|
+
}
|
136
|
+
synFields.push(i);
|
137
|
+
dynField['fields'] = synFields;
|
138
|
+
}
|
139
|
+
solr.schemaFields[i] = item;
|
140
|
+
}
|
141
|
+
//Populate other data in this field that would not have been loaded in
|
142
|
+
// the show=schema variant
|
143
|
+
$.each(item, function(k, v) {
|
144
|
+
if (k == 'topTerms' || k == 'histogram') {
|
145
|
+
solr.schemaFields[i][k] = solr.lukeArrayToHash(v);
|
146
|
+
} else {
|
147
|
+
solr.schemaFields[i][k] = v;
|
148
|
+
}
|
149
|
+
});
|
150
|
+
});
|
151
|
+
//another optional callback; used in the init case to lay out the page
|
152
|
+
// after the data is loaded
|
153
|
+
if ($.isFunction(func)) {
|
154
|
+
func();
|
155
|
+
}
|
156
|
+
});
|
157
|
+
},
|
158
|
+
//some elements in the JSON response are arrays, where odd/even elements
|
159
|
+
// are the name/value, and convert it to a standard map/associative array
|
160
|
+
// incoming: ['foo', 'bar', 'bat', 'baz']
|
161
|
+
// output: {'foo':'bar', 'bat':baz'}
|
162
|
+
lukeArrayToHash: function(termsArr) {
|
163
|
+
var hash = new Object();
|
164
|
+
var temp;
|
165
|
+
//topTerms comes in as an array, with odd indexes the field name
|
166
|
+
// and even indexes the number
|
167
|
+
$.each(termsArr, function(i, item) {
|
168
|
+
if (i%2 ==0) {
|
169
|
+
temp = item;
|
170
|
+
} else {
|
171
|
+
hash[temp] = item;
|
172
|
+
}
|
173
|
+
});
|
174
|
+
return hash;
|
175
|
+
},
|
176
|
+
|
177
|
+
//gets the top Terms via an Ajax call the LukeRequestHandler for that field
|
178
|
+
// The callback is used here to redraw the table after the ajax call returns
|
179
|
+
getTopTerms: function(fieldName, numTerms, func) {
|
180
|
+
if (numTerms == undefined) {
|
181
|
+
var numTerms = 10;
|
182
|
+
}
|
183
|
+
if (isNaN(numTerms) || numTerms <=0 || numTerms.indexOf('.') != -1) {
|
184
|
+
return;
|
185
|
+
}
|
186
|
+
$.getJSON(solr.pathToLukeHandler+'?fl='+fieldName+'&wt=json&numTerms='+numTerms, function(data) {
|
187
|
+
solr.schemaFields[fieldName]['topTerms'] = solr.lukeArrayToHash(data.fields[fieldName].topTerms);
|
188
|
+
if ($.isFunction(func)) {
|
189
|
+
func(solr.schemaFields[fieldName]['topTerms'], fieldName);
|
190
|
+
}
|
191
|
+
});
|
192
|
+
},
|
193
|
+
|
194
|
+
// Displays the SchemaInfo in the main content panel
|
195
|
+
// dispayed on data load, and also when 'Home' is clicked
|
196
|
+
displaySchemaInfo: function() {
|
197
|
+
$('#mainInfo').html('');
|
198
|
+
$('#topTerms').html('');
|
199
|
+
$('#histogram').html('');
|
200
|
+
$('#mainInfo').append(solr.createSimpleText('Schema Information'));
|
201
|
+
//Make sure the uniqueKeyField and defaultSearchFields come first
|
202
|
+
$.each({'Unique Key':'uniqueKeyField', 'Default Search Field':'defaultSearchField'}, function(text, prop) {
|
203
|
+
if (solr.schemaInfo[prop] != undefined) {
|
204
|
+
$('#mainInfo').append(solr.createNameValueText(text, function(p) {
|
205
|
+
p.appendChild(solr.createLink(solr.schemaInfo[prop], solr.schemaInfo[prop]));
|
206
|
+
return p;
|
207
|
+
}));
|
208
|
+
}
|
209
|
+
});
|
210
|
+
$.each(solr.schemaInfo, function(i, item) {
|
211
|
+
if (i == 'uniqueKeyField' || i == 'defaultSearchField') {
|
212
|
+
//noop; we took care of this above
|
213
|
+
} else {
|
214
|
+
$('#mainInfo').append(solr.createNameValueText(i, item));
|
215
|
+
}
|
216
|
+
});
|
217
|
+
//Close all menus when we display schema home
|
218
|
+
solr.toggleMenus(undefined, ['fields', 'types', 'dynFields']);
|
219
|
+
},
|
220
|
+
|
221
|
+
// display a dynamic field in the main content panel
|
222
|
+
displayDynamicField: function(dynamicPattern) {
|
223
|
+
var df = solr.schemaDynamicFields[dynamicPattern];
|
224
|
+
$('#mainInfo').html('');
|
225
|
+
$('#topTerms').html('');
|
226
|
+
$('#histogram').html('');
|
227
|
+
$('#mainInfo').append(solr.createSimpleText('Dynamic Field: ' + dynamicPattern));
|
228
|
+
$('#mainInfo').append(solr.createNameValueText('Fields', function(p) {
|
229
|
+
if (df.fields != undefined) {
|
230
|
+
$.each(df.fields, function(i, item) {
|
231
|
+
p.appendChild(solr.createLink(item, item));
|
232
|
+
});
|
233
|
+
} else {
|
234
|
+
p.appendChild(document.createTextNode(' None currently in index'));
|
235
|
+
}
|
236
|
+
return p;
|
237
|
+
}));
|
238
|
+
var ft = solr.schemaTypes[df.type];
|
239
|
+
$('#mainInfo').append(solr.createNameValueText('Field Type', function(p) {
|
240
|
+
p.appendChild(solr.createLink(df.type, df.type, solr.displayFieldType));
|
241
|
+
return p;
|
242
|
+
}));
|
243
|
+
if (df.flags != undefined) {
|
244
|
+
$('#mainInfo').append(solr.createNameValueText('Properties', solr.createTextFromFlags(df.flags, df.type)));
|
245
|
+
}
|
246
|
+
solr.displayAnalyzer(ft.indexAnalyzer, 'Index Analyzer', true);
|
247
|
+
solr.displayAnalyzer(ft.queryAnalyzer, 'Query Analyzer', true);
|
248
|
+
|
249
|
+
solr.toggleMenus('dynFields', ['fields', 'types'], dynamicPattern);
|
250
|
+
},
|
251
|
+
|
252
|
+
// display a field type in the main area
|
253
|
+
displayFieldType: function(typeName) {
|
254
|
+
var ft = solr.schemaTypes[typeName];
|
255
|
+
$('#mainInfo').html('');
|
256
|
+
$('#topTerms').html('');
|
257
|
+
$('#histogram').html('');
|
258
|
+
$('#mainInfo').append(solr.createSimpleText('Field Type: ' + typeName));
|
259
|
+
$('#mainInfo').append(solr.createNameValueText('Fields', function(p) {
|
260
|
+
if (ft.fields != undefined) {
|
261
|
+
$.each(ft.fields, function(i, item) {
|
262
|
+
if (solr.schemaFields[item] != undefined) {
|
263
|
+
p.appendChild(solr.createLink(item, item));
|
264
|
+
} else {
|
265
|
+
p.appendChild(solr.createLink(item, item, solr.displayDynamicField));
|
266
|
+
}
|
267
|
+
p.appendChild(document.createTextNode(' '));
|
268
|
+
});
|
269
|
+
} else {
|
270
|
+
p.appendChild(document.createTextNode('No fields in index'));
|
271
|
+
}
|
272
|
+
return p;
|
273
|
+
}));
|
274
|
+
$('#mainInfo').append(solr.createNameValueText('Tokenized', ft.tokenized));
|
275
|
+
$('#mainInfo').append(solr.createNameValueText('Class Name', ft.className));
|
276
|
+
|
277
|
+
solr.displayAnalyzer(ft.indexAnalyzer, 'Index Analyzer');
|
278
|
+
solr.displayAnalyzer(ft.queryAnalyzer, 'Query Analyzer');
|
279
|
+
solr.toggleMenus('types', ['fields', 'dynFields'], typeName);
|
280
|
+
},
|
281
|
+
|
282
|
+
//Displays information about an Analyzer in the main content area
|
283
|
+
displayAnalyzer: function(analyzer, type, shouldCollapse) {
|
284
|
+
var tid = type.replace(' ', '');
|
285
|
+
var collapse = shouldCollapse && (analyzer.tokenizer != undefined || analyzer.filters != undefined);
|
286
|
+
$('#mainInfo').append(solr.createNameValueText(type, function(p) {
|
287
|
+
p.appendChild(document.createTextNode(analyzer.className + ' '));
|
288
|
+
if (collapse) {
|
289
|
+
p.appendChild(solr.createLink(type, 'Details', function() {
|
290
|
+
$('#'+tid).toggle("slow");
|
291
|
+
}));
|
292
|
+
}
|
293
|
+
return p;
|
294
|
+
}));
|
295
|
+
var adiv = document.createElement('div');
|
296
|
+
adiv.id=tid;
|
297
|
+
adiv.className='analyzer';
|
298
|
+
if (collapse) {
|
299
|
+
adiv.style.display='none';
|
300
|
+
}
|
301
|
+
if (analyzer.tokenizer != undefined) {
|
302
|
+
adiv.appendChild(solr.createNameValueText("Tokenizer Class", analyzer.tokenizer.className));
|
303
|
+
}
|
304
|
+
if (analyzer.filters != undefined) {
|
305
|
+
adiv.appendChild(solr.createNameValueText('Filters', ''));
|
306
|
+
var f = document.createElement('ol');
|
307
|
+
$.each(analyzer.filters, function(i, item) {
|
308
|
+
var fil = document.createElement('li');
|
309
|
+
var filterText = item.className;
|
310
|
+
if (item.args != undefined) {
|
311
|
+
filterText += ' args:{'
|
312
|
+
$.each(item.args, function(fi, fitem) {
|
313
|
+
filterText += fi + ': ' + fitem + ' ';
|
314
|
+
});
|
315
|
+
filterText +='}';
|
316
|
+
fil.innerHTML = filterText;
|
317
|
+
f.appendChild(fil);
|
318
|
+
}
|
319
|
+
});
|
320
|
+
adiv.appendChild(f);
|
321
|
+
}
|
322
|
+
$('#mainInfo').append(adiv);
|
323
|
+
},
|
324
|
+
|
325
|
+
// display information about a Field in the main content area
|
326
|
+
// and its TopTerms and Histogram in related divs
|
327
|
+
displayField: function(fieldName) {
|
328
|
+
var field = solr.schemaFields[fieldName];
|
329
|
+
var isDynamic = field.dynamicBase != undefined ? true : false;
|
330
|
+
var ft;
|
331
|
+
var ftName;
|
332
|
+
$('#mainInfo').html('');
|
333
|
+
$('#topTerms').html('');
|
334
|
+
$('#histogram').html('');
|
335
|
+
$('#mainInfo').append(solr.createSimpleText('Field: ' + fieldName));
|
336
|
+
|
337
|
+
//For regular fields, we take their properties; for dynamicFields,
|
338
|
+
// we take them from their dynamicField definitions
|
339
|
+
if (isDynamic) {
|
340
|
+
ftName = solr.schemaDynamicFields[field.dynamicBase].type
|
341
|
+
$('#mainInfo').append(solr.createNameValueText('Dynamically Created From Pattern', function(p) {
|
342
|
+
p.appendChild(solr.createLink(field.dynamicBase, field.dynamicBase, solr.displayDynamicField));
|
343
|
+
return p;
|
344
|
+
}));
|
345
|
+
} else {
|
346
|
+
ftName = field.type;
|
347
|
+
}
|
348
|
+
ft = solr.schemaTypes[field.type];
|
349
|
+
$('#mainInfo').append(solr.createNameValueText('Field Type', function(p) {
|
350
|
+
p.appendChild(solr.createLink(ftName, ftName, solr.displayFieldType));
|
351
|
+
return p;
|
352
|
+
}));
|
353
|
+
if (solr.schemaFlags != '') {
|
354
|
+
$.each({'flags':'Properties', 'schema':'Schema', 'index':'Index'}, function(prop, text) {
|
355
|
+
if (field[prop] != undefined) {
|
356
|
+
$('#mainInfo').append(solr.createNameValueText(text, solr.createTextFromFlags(field[prop], ft)));
|
357
|
+
}
|
358
|
+
});
|
359
|
+
}
|
360
|
+
$.each({'copySources':'Copied From', 'copyDests':'Copied Into'}, function(prop, text) {
|
361
|
+
if (field[prop] != undefined && field[prop] != '') {
|
362
|
+
$('#mainInfo').append(solr.createNameValueText(text, function(p) {
|
363
|
+
$.each(field[prop], function(i, item) {
|
364
|
+
p.appendChild(solr.createLink(item, item));
|
365
|
+
p.appendChild(document.createTextNode(' '));
|
366
|
+
});
|
367
|
+
return p;
|
368
|
+
}));
|
369
|
+
}
|
370
|
+
});
|
371
|
+
if (field.positionIncrementGap != undefined) {
|
372
|
+
$('#mainInfo').append(solr.createNameValueText('Position Increment Gap', field.positionIncrementGap));
|
373
|
+
}
|
374
|
+
solr.displayAnalyzer(ft.indexAnalyzer, 'Index Analyzer', true);
|
375
|
+
solr.displayAnalyzer(ft.queryAnalyzer, 'Query Analyzer', true);
|
376
|
+
if (field.docs != undefined) {
|
377
|
+
$('#mainInfo').append(solr.createNameValueText('Docs', field.docs));
|
378
|
+
}
|
379
|
+
if (field.distinct != undefined) {
|
380
|
+
$('#mainInfo').append(solr.createNameValueText('Distinct', field.distinct));
|
381
|
+
}
|
382
|
+
|
383
|
+
if (field.topTerms != undefined) {
|
384
|
+
solr.displayTopTerms(field.topTerms, fieldName);
|
385
|
+
}
|
386
|
+
|
387
|
+
if (field.histogram != undefined) {
|
388
|
+
solr.drawHistogram(field.histogram);
|
389
|
+
}
|
390
|
+
solr.toggleMenus('fields', ['types', 'dynFields'], fieldName);
|
391
|
+
},
|
392
|
+
|
393
|
+
//utility method to create a single sentence list of properties from a flag set
|
394
|
+
// or pass it on, if the flags are (unstored field)
|
395
|
+
createTextFromFlags: function(fieldFlags, fieldType) {
|
396
|
+
var value;
|
397
|
+
if (fieldFlags != '(unstored field)') {
|
398
|
+
var value = '';
|
399
|
+
for (var i=0;i<fieldFlags.length;i++) {
|
400
|
+
if (fieldFlags.charAt(i) != '-') {
|
401
|
+
value += solr.schemaFlags[fieldFlags.charAt(i)];
|
402
|
+
value += ', ';
|
403
|
+
}
|
404
|
+
}
|
405
|
+
value = value.substring(0, value.length-2);
|
406
|
+
} else {
|
407
|
+
value = fieldFlags;
|
408
|
+
}
|
409
|
+
return value;
|
410
|
+
},
|
411
|
+
|
412
|
+
//Store the currently highlighted menu item, as otherwise we
|
413
|
+
// must traverse all li menu items, which is very slow on schemas with
|
414
|
+
// large number of fields
|
415
|
+
// for example $('#menu ul li').siblings().removeClass('selected');
|
416
|
+
currentlyHighlightedMenuId: undefined,
|
417
|
+
|
418
|
+
//add a highlight to the currently selected menu item, and remove
|
419
|
+
// the highlights from all other menu items
|
420
|
+
highlightMenuItem: function(idToSelect) {
|
421
|
+
if (solr.currentlyHighlightedMenuId != undefined) {
|
422
|
+
$('#'+solr.currentlyHighlightedMenuId).removeClass('selected');
|
423
|
+
}
|
424
|
+
$('#'+idToSelect).addClass('selected');
|
425
|
+
solr.currentlyHighlightedMenuId = idToSelect;
|
426
|
+
},
|
427
|
+
|
428
|
+
//Opens one menu group, close the others, and optionally highlight one
|
429
|
+
// item, which should be in the opened menu
|
430
|
+
toggleMenus: function(idToShow, idsToHide, idToSelect) {
|
431
|
+
if (idToSelect != undefined) {
|
432
|
+
solr.highlightMenuItem(idToShow + idToSelect);
|
433
|
+
}
|
434
|
+
$('#'+idToShow).show("slow");
|
435
|
+
$.each(idsToHide, function(i, idToHide) {
|
436
|
+
$('#'+idToHide).hide("slow");
|
437
|
+
});
|
438
|
+
},
|
439
|
+
|
440
|
+
//A utility method to create a paragraph, which takes two arguments;
|
441
|
+
// an opening text, and either text or a callback function to follow
|
442
|
+
// any callback function must return the node passed into it
|
443
|
+
createNameValueText: function(openingText, func) {
|
444
|
+
var p = document.createElement('p');
|
445
|
+
p.appendChild(solr.createSimpleText(openingText + ': ', 'b'));
|
446
|
+
return solr.applyFuncToNode(p, func);
|
447
|
+
},
|
448
|
+
|
449
|
+
//utility method to create an HTML text element node
|
450
|
+
// with the literal text to place, and an optional function to apply
|
451
|
+
// any callback function must return the node passed into it
|
452
|
+
createSimpleText: function(text, n, func) {
|
453
|
+
if (n == undefined) {
|
454
|
+
n = 'h2';
|
455
|
+
}
|
456
|
+
var no= document.createElement(n);
|
457
|
+
no.appendChild(document.createTextNode(text));
|
458
|
+
return solr.applyFuncToNode(no, func);
|
459
|
+
},
|
460
|
+
|
461
|
+
//Utility method that applies a function or a string to append
|
462
|
+
// an additional child to a node
|
463
|
+
applyFuncToNode: function(no, func) {
|
464
|
+
if ($.isFunction(func)) {
|
465
|
+
no = func(no);
|
466
|
+
} else {
|
467
|
+
// if it is not a function, append it as a string
|
468
|
+
if (func != undefined) {
|
469
|
+
no.appendChild(document.createTextNode(' ' + func));
|
470
|
+
}
|
471
|
+
}
|
472
|
+
return no;
|
473
|
+
},
|
474
|
+
|
475
|
+
//show a table of top terms for a given field
|
476
|
+
displayTopTerms: function(topTerms, fieldName) {
|
477
|
+
$('#topTerms').html('');
|
478
|
+
var tbl = document.createElement('table');
|
479
|
+
tbl.className='topTerms';
|
480
|
+
var thead= document.createElement('thead');
|
481
|
+
var headerRow = document.createElement('tr');
|
482
|
+
$.each(['term', 'frequency'], function() {
|
483
|
+
var cell = document.createElement('th');
|
484
|
+
cell.innerHTML= this;
|
485
|
+
headerRow.appendChild(cell);
|
486
|
+
});
|
487
|
+
thead.appendChild(headerRow);
|
488
|
+
tbl.appendChild(thead);
|
489
|
+
var tbody = document.createElement('tbody');
|
490
|
+
|
491
|
+
var numTerms = 0;
|
492
|
+
$.each(topTerms, function(term, count) {
|
493
|
+
var row = document.createElement('tr');
|
494
|
+
var c1 = document.createElement('td');
|
495
|
+
c1.innerHTML=term;
|
496
|
+
var c2 = document.createElement('td');
|
497
|
+
c2.innerHTML=count;
|
498
|
+
row.appendChild(c1);
|
499
|
+
row.appendChild(c2);
|
500
|
+
tbody.appendChild(row);
|
501
|
+
numTerms++;
|
502
|
+
});
|
503
|
+
tbl.appendChild(tbody);
|
504
|
+
|
505
|
+
//create a header along with an input widget so the user
|
506
|
+
// can request a different number of Top Terms
|
507
|
+
var h2 = document.createElement('h2');
|
508
|
+
h2.appendChild(document.createTextNode('Top '));
|
509
|
+
var termsGetter = document.createElement('input');
|
510
|
+
termsGetter.type='text';
|
511
|
+
termsGetter.size=5;
|
512
|
+
termsGetter.value=numTerms;
|
513
|
+
|
514
|
+
termsGetter.onchange=function() {
|
515
|
+
solr.getTopTerms(fieldName, this.value, solr.displayTopTerms);
|
516
|
+
}
|
517
|
+
h2.appendChild(termsGetter);
|
518
|
+
h2.appendChild(document.createTextNode(' Terms'));
|
519
|
+
$('#topTerms').append(h2);
|
520
|
+
|
521
|
+
document.getElementById('topTerms').appendChild(tbl);
|
522
|
+
$('#topTerms').append(tbl);
|
523
|
+
},
|
524
|
+
|
525
|
+
//draws a histogram, taking a map of values and an optional total height and width for the table
|
526
|
+
drawHistogram: function(histogram, totalHeightArg, totalWidthArg) {
|
527
|
+
$('#histogram').html('');
|
528
|
+
$('#histogram').append(solr.createSimpleText('Histogram'));
|
529
|
+
var max = 0;
|
530
|
+
var bars =0;
|
531
|
+
//find the # of columns and max value in the histogram
|
532
|
+
// so we can create an appropriately scaled chart
|
533
|
+
$.each(histogram, function(i, item) {
|
534
|
+
if (item > max) max = item;
|
535
|
+
bars += 1;
|
536
|
+
});
|
537
|
+
if (max ==0) {
|
538
|
+
$('#histogram').append(solr.createNameValueText('No histogram available'));
|
539
|
+
} else {
|
540
|
+
var totalHeight = totalHeightArg == undefined ? 208 : totalHeightArg;
|
541
|
+
var totalWidth = totalWidthArg == undefined ? 160 : totalWidthArg;
|
542
|
+
var tbl = document.createElement('table');
|
543
|
+
tbl.style.width=totalWidth+'px';
|
544
|
+
tbl.className = 'histogram';
|
545
|
+
var h = document.createElement('tbody');
|
546
|
+
var r = document.createElement('tr');
|
547
|
+
var r2 = document.createElement('tr');
|
548
|
+
$.each(histogram, function(i, item) {
|
549
|
+
var c = document.createElement('td');
|
550
|
+
c.innerHTML=item+'<div style="width:'+totalWidth/bars+'px;height:'+(item*totalHeight/max)+'px;background:blue"> </div>';
|
551
|
+
r.appendChild(c);
|
552
|
+
var c2 = document.createElement('td');
|
553
|
+
c2.innerHTML='' + i;
|
554
|
+
r2.appendChild(c2);
|
555
|
+
});
|
556
|
+
h.appendChild(r);
|
557
|
+
h.appendChild(r2);
|
558
|
+
tbl.appendChild(h);
|
559
|
+
$('#histogram').append(tbl);
|
560
|
+
}
|
561
|
+
},
|
562
|
+
|
563
|
+
//dynamically creates a link to be appended
|
564
|
+
createLink: function(idToDisplay, linkText, linkFunction) {
|
565
|
+
var link = document.createElement('a');
|
566
|
+
if (!$.isFunction(linkFunction)) {
|
567
|
+
linkFunction = solr.displayField
|
568
|
+
}
|
569
|
+
link.onclick=function() {
|
570
|
+
linkFunction(idToDisplay);
|
571
|
+
return false;
|
572
|
+
};
|
573
|
+
link.href='#';
|
574
|
+
link.innerHTML=linkText;
|
575
|
+
return link;
|
576
|
+
},
|
577
|
+
|
578
|
+
//Creates a menu header that can expand or collapse its children
|
579
|
+
createMenuHeader: function(text, idToShow, idsToHide) {
|
580
|
+
var head = document.createElement('h3');
|
581
|
+
var a = document.createElement('a');
|
582
|
+
a.onclick=function() {
|
583
|
+
solr.toggleMenus(idToShow, idsToHide);
|
584
|
+
return false;
|
585
|
+
};
|
586
|
+
a.href='#';
|
587
|
+
a.innerHTML=text;
|
588
|
+
head.appendChild(a);
|
589
|
+
return head;
|
590
|
+
},
|
591
|
+
|
592
|
+
//Creates an element in a menu (e.g. each field in a list of fields)
|
593
|
+
createMenuItem: function(tagName, text, link, type, func) {
|
594
|
+
var fieldEle = document.createElement('li');
|
595
|
+
fieldEle.id=type+text;
|
596
|
+
var funct = func == undefined ? undefined : func;
|
597
|
+
fieldEle.appendChild(solr.createLink(text, link, funct));
|
598
|
+
return fieldEle;
|
599
|
+
},
|
600
|
+
|
601
|
+
//populates the menu div
|
602
|
+
createMenu: function(menuId) {
|
603
|
+
var m = $('#'+menuId);
|
604
|
+
var home = document.createElement('h2');
|
605
|
+
home.appendChild(solr.createLink('Home', 'Home', solr.displaySchemaInfo));
|
606
|
+
m.append(home);
|
607
|
+
m.append(solr.createMenuHeader('Fields', 'fields', ['types', 'dynFields']));
|
608
|
+
var fields= document.createElement('ul');
|
609
|
+
fields.style.display='none';
|
610
|
+
fields.id = 'fields';
|
611
|
+
$.each(solr.schemaFields, function(i, item) {
|
612
|
+
fields.appendChild(solr.createMenuItem('li', i, i, fields.id));
|
613
|
+
});
|
614
|
+
m.append(fields);
|
615
|
+
m.append(solr.createMenuHeader('Dynamic Fields', 'dynFields', ['fields', 'types']));
|
616
|
+
var dyns = document.createElement('ul');
|
617
|
+
dyns.style.display = 'none';
|
618
|
+
dyns.id = 'dynFields';
|
619
|
+
$.each(solr.schemaDynamicFields, function(i, item) {
|
620
|
+
dyns.appendChild(solr.createMenuItem('li', i,i, dyns.id, solr.displayDynamicField));
|
621
|
+
});
|
622
|
+
m.append(dyns);
|
623
|
+
m.append(solr.createMenuHeader('Field Types', 'types', ['fields', 'dynFields']));
|
624
|
+
var types = document.createElement('ul');
|
625
|
+
types.style.display='none';
|
626
|
+
types.id='types';
|
627
|
+
$.each(this.schemaTypes, function(i, item) {
|
628
|
+
types.appendChild(solr.createMenuItem('li', i, i,types.id, solr.displayFieldType));
|
629
|
+
});
|
630
|
+
m.append(types);
|
631
|
+
}
|
632
|
+
};
|
633
|
+
|
634
|
+
window[libName] = solr;
|
635
|
+
})(jQuery, 'solr');
|
636
|
+
$(document).ready(function() {
|
637
|
+
solr.init();
|
638
|
+
});
|
639
|
+
|
640
|
+
$(window).unload( function() {
|
641
|
+
solr = null;
|
642
|
+
$('#mainInfo').html('');
|
643
|
+
$('#menu').html('');
|
644
|
+
$('#topTerms').html('');
|
645
|
+
$('#histogram').html('');
|
646
|
+
});
|
647
|
+
|
648
|
+
</script>
|
649
|
+
<%-- do a verbatim include so we can use the local vars --%>
|
650
|
+
<%@include file="header.jsp" %>
|
651
|
+
<div id="schemaTop">
|
652
|
+
<h2>Schema Browser | See <a href="file/?file=schema.xml">Raw Schema.xml</a></h2>
|
653
|
+
</div>
|
654
|
+
<div id="menu"></div>
|
655
|
+
<div id="content">
|
656
|
+
<div id="mainInfo"><h2>Please wait...loading and parsing Schema Information from LukeRequestHandler</h2><p>If it does not load or your browser is not javascript or ajax-capable, you may wish to examine your schema using the <a href="luke?wt=xslt&tr=luke.xsl">Server side transformed LukeRequestHandler</a> or the raw <a href="file/?file=schema.xml">schema.xml</a> instead.</div>
|
657
|
+
<div id="topTerms"></div>
|
658
|
+
<div id="histogram"></div>
|
659
|
+
</div>
|
660
|
+
</body>
|
661
|
+
</html>
|