You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by sz <si...@gallerysystems.com> on 2016/06/07 20:59:17 UTC
Index and Search file path
Hi all,
Recently I run into issue indexing and searching path value.
For example, I have field with solr type "string". I tried to store a
file path with value '\\root\path1\path2'. After successfully indexing, I
checked via Solr Admin UI and see the value is '\\\\root\\path1\\path2'.
Apparently Solr/Lucense added the escape character '\' automatically to '\'
in original value. And to search this value, I have to manually added '\'
to my search term.
I am wondering why Solr add it automatically during indexing and I have to
add it manual during query. My issues with it is that even I added the
escape '\' manually, it wont' work in join query (search in subdocuments).
I am aware Lucene/Solr has some special characters such as + - && || ! ( ) {
} [ ] ^ " ~ * ? : \ /
. But when I tried different characters, Solr only adds escape character
'\' to special character '"' and '\'. For the rest, the value in index is
as is without escape character '\'.
Here is my testing value
(a^b:c\d~e&f+ag"h\i*j-k[l?m|n}
In solr index, the value is
(a^b:c\\d~e&f+ag\"h\\i*j-k[l?m|n}
Does anyone has the experience indexing and search value of file path?
Thanks,
SZ
--
View this message in context: http://lucene.472066.n3.nabble.com/Index-and-Search-file-path-tp4281112.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Index and Search file path
Posted by sz <si...@gallerysystems.com>.
Hi Shawn,
Thanks for the reply. You are right - once I choose XML format, i can see
the extra escape character '\' is not there any more.
As I mentioned, I was able to query with added escape '\' in my query.
Something like below works.
pathField:\\\root\path1\path2
But if this query is apply to subdocument, something like below, it does NOT
work.
{!parent which=parentType:1}+pathField:\\\root\path1\path2
Any idea how to make it work?
Thanks,
SZ
--
View this message in context: http://lucene.472066.n3.nabble.com/Index-and-Search-file-path-tp4281112p4281237.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Index and Search file path
Posted by Shawn Heisey <ap...@elyograg.org>.
On 6/7/2016 2:59 PM, sz wrote:
> Hi all, Recently I run into issue indexing and searching path value.
> For example, I have field with solr type "string". I tried to store a
> file path with value '\\root\path1\path2'. After successfully
> indexing, I checked via Solr Admin UI and see the value is
> '\\\\root\\path1\\path2'. Apparently Solr/Lucense added the escape
> character '\' automatically to '\' in original value. And to search
> this value, I have to manually added '\' to my search term. I am
> wondering why Solr add it automatically during indexing and I have to
> add it manual during query. My issues with it is that even I added the
> escape '\' manually, it wont' work in join query (search in
> subdocuments).
The backslash character is the escape character in the syntax of a lot
of languages and data formats.
When you get JSON results, if there is a literal backslash, it shows up
as two backslashes -- one to say "the next character is escaped" and
then the escaped character. When the data returned by a query (which is
stored internally with only one backslash) is run through standard JSON
encoding, the backslashes are escaped. If you were to ask for XML
results, I think you'd find that there's only one backslash, because XML
works very differently than JSON.
Solr queries are the same way. Characters that should be treated
literally are preceded by a backslash, so if you want an actual
backslash in your query, you have to put two of them, or run your query
through a function that will escape special characters, which is going
to add a backslash to each special character -- including existing
backslashes.
Thanks,
Shawn