Ah, okay, I see the usage now. In SQL the right operand of LIKE can be either a literal wildcard pattern or an expression which is evaluated per-row during the query. Solr/Lucene has the former, but not the latter. The wildcard pattern will be fixed at the start of the search.

-- Jack Krupansky

-----Original Message----- From: Lochschmied, Alexander
Sent: Monday, August 13, 2012 3:05 AM
To: solr-user@lucene.apache.org
Subject: AW: AW: Indexing wildcard patterns

Here is what we do in SQL:

mysql> select * from _tbl;
+----+------------+
| id | field      |
+----+------------+
|  1 | plain text |
|  2 | wil_c%     |
+----+------------+
2 rows in set (0.14 sec)

mysql> SELECT * FROM _TBL WHERE 'wildcard' LIKE FIELD;
+----+--------+
| id | field  |
+----+--------+
|  2 | wil_c% |
+----+--------+
1 row in set (0.12 sec)

So the patterns are associated with the actual documents in the database. We use those fields as a means to manually customize some searches.

Thanks,
Alexander

-----Ursprüngliche Nachricht-----
Von: Jack Krupansky [mailto:j...@basetechnology.com]
Gesendet: Freitag, 10. August 2012 18:39
An: solr-user@lucene.apache.org
Betreff: Re: AW: Indexing wildcard patterns

"Doc1 has the pattern "AB%CD%" associated with it (somehow?!)."

You need to clarify what you mean by that.

To be clear, Solr support for wildcards is a superset of the SQL LIKE operator, and the patterns used in the LIKE operator are NOT stored in the table data, but used at query time - same with Solr. In SQL you do not "associate" patterns with table data, but rather you query data using a pattern.

Step back and describe the problem you are trying to solve rather than prematurely jumping into a proposed solution.

So, if there is something you already do in SQL and now wish to do it in Solr, please tell us about it.

-- Jack Krupansky

-----Original Message-----
From: Lochschmied, Alexander
Sent: Friday, August 10, 2012 5:25 AM
To: solr-user@lucene.apache.org
Subject: AW: Indexing wildcard patterns

I thought my question might be confusing...

I know about Solr providing wildcards in queries, but my problem is different.

I have those patterns associated with my searchable documents before any actual search is done. I need Solr to return the document which is associated with matching patterns. User does not enter the wildcard pattern; wildcard pattern must be tested by Solr automatically.

So in the example I provided below, a user might enter " ABCDXYZ " and I need Solr to return Doc1, as Doc1 has the pattern "AB%CD%" associated with it (somehow?!).

Thanks,
Alexander


-----Ursprüngliche Nachricht-----
Von: Ahmet Arslan [mailto:iori...@yahoo.com]
Gesendet: Freitag, 10. August 2012 10:34
An: solr-user@lucene.apache.org
Betreff: Re: Indexing wildcard patterns



--- On Fri, 8/10/12, Lochschmied, Alexander <alexander.lochschm...@vishay.com> wrote:

From: Lochschmied, Alexander <alexander.lochschm...@vishay.com>
Subject: Indexing wildcard patterns
To: "solr-user@lucene.apache.org" <solr-user@lucene.apache.org>
Date: Friday, August 10, 2012, 11:07 AM Coming from a SQL database
based search system, we already have a set of defined patterns
associated with our searchable documents.

% matches no or any number of characters _ matches one character

Example:
Doc 1: 'AB%CD', 'AB%CD%'
Doc 2: 'AB_CD'
...

Thus Doc 1 matches
ABXYZCD
ABCD
ABCDXYZ
...

Whereas Doc 2 matches only
ABXCD
ABYCD
ABZCD
...

This can be achieved in SQL WHERE statements using the LIKE operator.

Is there a (similar) way to this in Solr?

Yes, wildcard search in solr

* matches no or any number of characters ? matches one character

http://lucene.apache.org/core/3_6_0/queryparsersyntax.html#Wildcard%20Searches

Reply via email to