Skip to content
Browse files

Fixed search term returning null exception and updated deprecated use…

… of TermAttribute
  • Loading branch information...
1 parent 9ffb489 commit 0fdcb77440004650f32009a671322ef8aba88557 @sparkica sparkica committed Jan 24, 2013
View
54 module/scripts/suggestterm.suggest.js
@@ -10,12 +10,10 @@
$.suggest.suggest.prototype,
{
create_item: function(data,response_data) {
- console.log("---- create item ----");
var css = this.options.css;
var li = $("<li>").addClass(css.item);
var name = $("<div>").addClass(css.item_name)
-
.append($("<label>")
.append($.suggest.strongify(data.name,response_data.prefix)));
// this converts html escaped strings like "&amp;"
@@ -29,7 +27,6 @@
},
request: function(value, cursor) {
- console.log("---- request ---");
var self = this,
o = this.options;
@@ -38,85 +35,43 @@
data[o.query_param_name] = query;
clearTimeout(this.request.timeout);
- console.log("Data before ajax call");
data["prefix"] = query;
data["type_strict"] = "classes";
data["type"] = theProject.id;
var url = o.service_url + o.service_path + "?" + $.param(data, true);
- console.log(url);
- console.log(data);
-
var ajax_options = {
url: o.service_url + o.service_path,
data: data,
traditional: true,
-/* beforeSend: function(xhr) {
- console.log("--- before send ---");
- console.log(xhr);
- var calls = self.input.data("request.count.suggest") || 0;
- calls += 1;
- self.trackEvent(self.name, "request", "count", calls);
- self.input.data("request.count.suggest", calls);
- },
-*/ error: function(xhr) {
- console.log("--- request error --");
- console.log(xhr);
+ error: function(xhr) {
self.status_error();
-
self.trackEvent(self.name, "request", "error", {
url: this.url,
response: xhr ? xhr.responseText : ''
});
self.input.trigger("fb-error", Array.prototype.slice.call(arguments));
},
complete: function(xhr) {
- console.log(" -- complete --");
if (xhr) {
self.trackEvent(self.name, "request", "tid",
xhr.getResponseHeader("X-Metaweb-TID"));
}
},
success: function(data) {
- console.log("--- success ---");
- console.log(data);
$.suggest.cache[url] = data;
data.prefix = value; // keep track of prefix to match up response with input value
self.response(data, cursor ? cursor : -1);
-
},
dataType: "json",
cache: true
};
this.request.timeout = setTimeout(function() {
- console.log("Doing something...");
$.ajax(ajax_options);
}, o.xhr_delay);
- },
-
- response: function(data){
- console.log("---- response ----");
- console.log(data);
- var o = this.options,
- p = this.pane,
- s = this.get_selected() || [];
- if (p.is(":visible") && s.length) {
- var sug_data = s.data("data.suggest");
- if (sug_data && data.id === sug_data.id) {
- this.flyoutpane.html('<div class="fbs-flyout-content">' + data.description + '</div>');
- this.flyout_position(s);
- this.flyoutpane.show()
- .data("data.suggest", sug_data);
- this.input.trigger("fb-flyoutpane-show", this);
- }
- }
-
- },
-
- flyout_request:function(data){
- console.log("----- flyout request ---");
-
+ },
+ flyout_request:function(data){
var self = this;
var o = this.options,
@@ -145,7 +100,6 @@
},
flyout_response:function(data){
- console.log("---- flyout response ----");
var o = this.options,
p = this.pane,
s = this.get_selected() || [];
@@ -162,8 +116,6 @@
}
}));
-
-
$.extend($.suggest.suggestterm, {
defaults: $.extend(
true,
View
1 src/org/deri/grefine/rdf/commands/SuggestTermCommand.java
@@ -38,7 +38,6 @@ public void doGet(HttpServletRequest request, HttpServletResponse response)
String projectId = request.getParameter("type");
response.setHeader("Content-Type", "application/json");
- //response.setStatus(HttpServletResponse.SC_OK);
JSONWriter writer = new JSONWriter(response.getWriter());
String type = request.getParameter("type_strict");
View
24 src/org/deri/grefine/rdf/vocab/imp/VocabularySearcher.java
@@ -12,7 +12,6 @@
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.SimpleAnalyzer;
import org.apache.lucene.analysis.TokenStream;
-//import org.apache.lucene.analysis.tokenattributes.TermAttribute;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -61,14 +60,6 @@
private IndexSearcher searcher;
private Directory _directory;
-
-// public VocabularySearcher(File dir) throws IOException {
-// _directory = new SimpleFSDirectory(new File(dir, "luceneIndex"));
-// writer = new IndexWriter(_directory, new SimpleAnalyzer(),
-// IndexWriter.MaxFieldLength.LIMITED);
-// writer.commit();
-// searcher = new IndexSearcher(_directory);
-// }
public VocabularySearcher(File dir) throws IOException {
_directory = new SimpleFSDirectory(new File(dir, "luceneIndex"));
@@ -109,20 +100,7 @@ public void importAndIndexVocabulary(String name, String uri, Repository reposit
public List<SearchResultItem> searchClasses(String str, String projectId)
throws ParseException, IOException {
Query query = prepareQuery(str, CLASS_TYPE, projectId);
- if(query == null)
- {
- logger.error("Query null");
- }
-
- logger.info("Query: " + query);
-
- TopDocs docs = searcher.search(query, getMaxDoc());
-
- if(docs == null) {
- logger.error("Docs null...");
- }
-
- logger.info("Got docs.");
+ TopDocs docs = searcher.search(query, getMaxDoc());
return prepareSearchResults(docs);
}

0 comments on commit 0fdcb77

Please sign in to comment.
Something went wrong with that request. Please try again.