You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Mag Gam <ma...@gmail.com> on 2006/08/24 15:54:52 UTC

Document Get question

Is it possible to get Document Name, instead of its entire path?

Currently, i have something like this:
out.println (doc.get ("path"));   // Which gives me /documents/file.txt

Is it possible to get  "file.txt"

Re: Document Get question

Posted by Ronnie Kolehmainen <ro...@ub.uu.se>.
If you want to get "file.txt" out of "/documents/file.txt" simply cut of
everything before the last "/":

  String path = doc.get("path");
  String name = path != null ? path.substring(path.lastIndexOf("/") + 1) :
path;

Otherwise, if you want to store only the name in the index, you will have to do
something similar to the above when you create the document field in the
indexing process.

/Ronnie


Citerar Mag Gam <ma...@gmail.com>:

> Is it possible to get Document Name, instead of its entire path?
> 
> Currently, i have something like this:
> out.println (doc.get ("path"));   // Which gives me /documents/file.txt
> 
> Is it possible to get  "file.txt"
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Document Get question

Posted by Hasan Diwan <ha...@gmail.com>.
On 24/08/06, Mag Gam <ma...@gmail.com> wrote:
> Is it possible to get Document Name, instead of its entire path?
>
> Currently, i have something like this:
> out.println (doc.get ("path"));   // Which gives me /documents/file.txt

doc.get("path").split("/")[doc.get("path").split("/").length - 1]

-- 
Cheers,
Hasan Diwan <ha...@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Document Get question

Posted by Suba Suresh <su...@wolfram.com>.
Index the "filename" when you are indexing as you did the "path". You 
can get it back with doc.get("filename");

suba suresh.

Mag Gam wrote:
> Is it possible to get Document Name, instead of its entire path?
> 
> Currently, i have something like this:
> out.println (doc.get ("path"));   // Which gives me /documents/file.txt
> 
> Is it possible to get  "file.txt"
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org