static string RemapUriToPath(Hashtable all_hits_by_uri, Hit hit) { string exact_name; if (hit.GetFirstProperty(Property.IsChildPropKey) == "true") { exact_name = hit.GetFirstProperty("parent:" + Property.ExactFilenamePropKey); } else { exact_name = hit.GetFirstProperty(Property.ExactFilenamePropKey); } string parent_uri_str = hit.GetFirstProperty(Property.ParentDirUriPropKey); if (parent_uri_str == null) { return(exact_name); } else { return(Path.Combine(RemapUriToPath(all_hits_by_uri, (Hit)all_hits_by_uri [parent_uri_str]), exact_name)); } }
public SnippetRequest (Query query, Hit hit) : base (false) { this.QueryTerms = new string [query.StemmedText.Count]; int i = 0; foreach (string term in query.StemmedText) { this.QueryTerms [i] = term; ++i; } this.Hit = hit; }
static string RemapUriToPath (Hashtable all_hits_by_uri, Hit hit) { string exact_name; if (hit.GetFirstProperty (Property.IsChildPropKey) == "true") exact_name = hit.GetFirstProperty ("parent:" + Property.ExactFilenamePropKey); else exact_name = hit.GetFirstProperty (Property.ExactFilenamePropKey); string parent_uri_str = hit.GetFirstProperty (Property.ParentDirUriPropKey); if (parent_uri_str == null) return exact_name; else return Path.Combine (RemapUriToPath (all_hits_by_uri, (Hit) all_hits_by_uri [parent_uri_str]), exact_name); }
public ISnippetReader GetSnippet (string[] query_terms, Hit hit, bool full_text, int ctx_length, int snp_length) { return null; }
static int DumpOneIndex_Metadata(string index_name, ArrayList uris, bool show_properties) { LuceneQueryingDriver driver; driver = new LuceneQueryingDriver(index_name, -1, true); Hashtable all_hits_by_uri = null; ArrayList all_hits = null; if (uris.Count == 0 || index_name == "FileSystemIndex") { all_hits_by_uri = driver.GetAllHitsByUri(); all_hits = new ArrayList(all_hits_by_uri.Values); } // A hard-wired hack if (index_name == "FileSystemIndex") { foreach (Hit hit in all_hits) { string internal_uri; if (hit [Property.IsChildPropKey] == "true") { string path = RemapUriToPath(all_hits_by_uri, hit); internal_uri = UriFu.UriToEscapedString(hit.ParentUri); hit.ParentUri = UriFu.PathToFileUri(path); hit.Uri = UriFu.AddFragment(UriFu.PathToFileUri(path), hit.Uri.Fragment, true); } else { internal_uri = UriFu.UriToEscapedString(hit.Uri); hit.Uri = UriFu.PathToFileUri(RemapUriToPath(all_hits_by_uri, hit)); hit.AddProperty(Property.NewUnsearched("beagrep:InternalUri", internal_uri)); } } } ArrayList matching_hits; if (uris.Count == 0) { matching_hits = all_hits; } else { matching_hits = new ArrayList(driver.GetHitsForUris(RemapUris(driver, uris))); if (index_name == "FileSystemIndex") { for (int i = 0; i < matching_hits.Count; i++) { Hit hit = (Hit)matching_hits [i]; Hit mapped_hit = (Hit)all_hits_by_uri [hit.Uri]; matching_hits [i] = mapped_hit; } } } matching_hits.Sort(new HitByUriComparer()); foreach (Hit hit in matching_hits) { if (!show_properties) { Console.WriteLine("{0}: {1}", index_name, hit.Uri); continue; } Console.WriteLine(" Index: {0}", index_name); Console.WriteLine(" Uri: {0}", hit.Uri); if (hit.ParentUri != null) { Console.WriteLine("Parent: {0}", hit.ParentUri); } Console.WriteLine(" MimeT: {0}", hit.MimeType); Console.WriteLine(" Type: {0}", hit.Type); Console.WriteLine("Source: {0}", hit.Source); ArrayList props; props = new ArrayList(hit.Properties); props.Sort(); foreach (Property prop in props) { char [] legend = new char [4]; legend [0] = prop.IsMutable ? 'm' : ' '; legend [1] = prop.IsSearched ? 's' : ' '; legend [2] = prop.IsPersistent ? 'p' : ' '; legend [3] = prop.Type == PropertyType.Text ? 't' : ' '; Console.WriteLine(" Prop: [{0}] {1} = '{2}'", new String(legend), prop.Key, prop.Value); } Console.WriteLine(); } return(matching_hits.Count); }
public ISnippetReader GetSnippet (string[] query_terms, Hit hit, bool full_text, int ctx_length, int snp_length) { if (hit == null) return null; // Sanity-check: make sure this Hit actually came out of this Queryable if (QueryDriver.GetQueryable (hit.Source) != this) { string msg = String.Format ("Queryable mismatch in GetSnippet: {0} vs {1}", hit.Source, this); throw new Exception (msg); } try { return iqueryable.GetSnippet (query_terms, hit, full_text, ctx_length, snp_length); } catch (Exception ex) { Logger.Log.Warn (ex, "Caught exception calling DoQuery on '{0}'", Name); } return null; }