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 Christopher Schultz <ch...@christopherschultz.net> on 2018/03/05 16:51:31 UTC
Alias field names when searching (not for results)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
All,
I'd like for users to be able to search a field by multiple names
without performing a "copy-field" when analyzing a document. Is that
possible? Whenever I search for "solr alias field" I get results about
how to re-name fields in the results.
Here's what I'd like to do. Let's say I have a document:
{
id: 1234,
field_1: valueA,
field_2: valueB,
field_3: valueC
}
I'd like users to be able to find this document using any of the
following queries:
field_1:valueA
f1:valueA
1:valueA
I just want the query parser to say "oh, 'f1' is an alias for
'field_1'" and substitute that when performing the search. Is that
possible?
- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQJRBAEBCAA7FiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlqddZMdHGNocmlzQGNo
cmlzdG9waGVyc2NodWx0ei5uZXQACgkQHPApP6U8pFgbFg/9HIgJgX4Lib2X4XYU
P2F4uW9TyDWtp6mA9xsfdYxRNe4K3yFPbkUUwJW2MI2V62SR6apB+TghOMqbmCD/
gaQ0CFWgLsn5Egulj2taUN+MAYD/4GMO9ltyXNc2g9siSMIDUS5N09fwJbxfBXrP
SPvSQqUOVD5wKCgoCXCVd+RM+SEClX4k1ZuWDbVAiO4YPpJwFy6+BN2uTCaqP3Ll
XOqn+/6ejnPCcvoQrTlE1/DiBTUti8H7V0LOjzEZns8YqZOAH+pAVxYRRQM5UzZS
pUBGpHokoaZ0tMf/aCmHp5pI5VWrxrXcS47csBRvoAn8Z7uRxH8p0wYE8BkGs2rw
dEzOSOKdhma11ZDkWKg2/sBw8v9swyWy9W3MuA0tqYzfZicsXT2GBHzyPDsqabDq
mBPWuxUdqZEaz+fE8SRsW84ELcqe1fbltscng/ZhNRkLOtmn6aeMc+XABhpcVE7o
Rfodl/PrQetgzZ4WLyzb7m2bz2w38x6WSPhuQIZHVrHNoCXG+gWY3zMxF6EBEFCV
CJvsXaQ1ZpGLjO/uCXJ9iHKxsSoUzWap9qws82xH3QJ52Q7vCoxF5G/2MZWvvgje
+MsZbh8L5D0HBM1jTKWx3X+r3FbdURu6P8yUFD/Hywy2J/jev1MiU4Zh3Yw+JByo
mR8TdvleHAHfA01tArVgk2yscqI=
=44DX
-----END PGP SIGNATURE-----
Re: Alias field names when searching (not for results)
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Rick,
On 3/6/18 6:39 PM, Rick Leir wrote:
> The first thing that came to mind is that you are planning not to
> have an app in front of Solr. Without a web app, you will need to
> trust whoever can get access to Solr. Maybe you are on an
> intranet.
Nope, we have a web application between the user and Solr. But I would
rather not parse the user's query string and re-write it so that the
search field-names are canonicalized.
Thanks,
- -chris
> On March 6, 2018 2:42:26 AM EST, "Emir Arnautović"
> <em...@sematext.com> wrote:
>> Hi, I did not try it, but the first thing that came to my mind is
>> to use edismax’s ability to define field aliases, something like
>> f.f1.fq=field_1. Note that it is not recommended to have field
>> name starting with number so not sure if it will work with “1”.
>>
>> HTH, Emir -- Monitoring - Log Management - Alerting - Anomaly
>> Detection Solr & Elasticsearch Consulting Support Training -
>> http://sematext.com/
>>
>>
>>
>>> On 5 Mar 2018, at 17:51, Christopher Schultz
>> <ch...@christopherschultz.net> wrote:
>>>
> All,
>
> I'd like for users to be able to search a field by multiple names
> without performing a "copy-field" when analyzing a document. Is
> that possible? Whenever I search for "solr alias field" I get
> results
>>> about
> how to re-name fields in the results.
>
> Here's what I'd like to do. Let's say I have a document:
>
> { id: 1234, field_1: valueA, field_2: valueB, field_3: valueC }
>
> I'd like users to be able to find this document using any of the
> following queries:
>
> field_1:valueA f1:valueA 1:valueA
>
> I just want the query parser to say "oh, 'f1' is an alias for
> 'field_1'" and substitute that when performing the search. Is that
> possible?
>
> -chris
>
>
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAltXTxwACgkQHPApP6U8
pFjHaA/9HYIjEges8puLMM8S+hwoKigLFzrGstbyWlrj5xHQsBnaeQbNCAv8TSO5
/Yx911UbJEc00etpJSiXVUbMWbwvzt1QmjKZADaUtUQpKJ3i/eORnFOu3/FXrojX
LJFWNxasO/gpFMqz6ADqdsfjKLDiqDQHg6letg0QVQ4d3k3diD3rahJaoJYg67/e
OeEOHqK9LTY+v9HGdLUzLQ87C2FQScsvnTX6vmCU7HLXcbJFOly/KXamL8gulM5g
+sVQbMSB1l+jkU3TOkWZ2ovJJzB49qVto2ZxcrT682GHyHq8sZIX6nsFSRZQl7Af
rCe0Esgdk0SPCf3NIcZugEKmlawqWulzDhheyFVDwc5kQhMmi9CFU+/JbQcT4yeM
Q72TRCdESnH8W9jWDa9+WuBT7PW+BPBogBXhTT2JgptqPxA2iUPl1M9HdjqiZd4K
qdt65YZrpomAQpcDBa4Rzl0yG7UXOuu5A3Ms6nYFyOB0lHdsQqtSVLVSgw1hw3g9
3tnRlyBi1FrrSpwDew8oNobMGVMigb3sxvjAO3lv6g6DH8YEcIyJE197xFVd5091
m+OQSpgO3iZtr7YxruDlM/fvofOLNevQS4LcdhXZoZ4Txi6cAi12svxId8w4yycq
SEOfyXZvd9S0IOdC4UZVfJ+8Ome6Iy1BV+WHsdO8SWKoHW+m7cE=
=x/55
-----END PGP SIGNATURE-----
Re: Alias field names when searching (not for results)
Posted by Rick Leir <rl...@leirtech.com>.
Christopher
The first thing that came to mind is that you are planning not to have an app in front of Solr. Without a web app, you will need to trust whoever can get access to Solr. Maybe you are on an intranet.
Thanks -- Rick
On March 6, 2018 2:42:26 AM EST, "Emir Arnautović" <em...@sematext.com> wrote:
>Hi,
>I did not try it, but the first thing that came to my mind is to use
>edismax’s ability to define field aliases, something like
>f.f1.fq=field_1. Note that it is not recommended to have field name
>starting with number so not sure if it will work with “1”.
>
>HTH,
>Emir
>--
>Monitoring - Log Management - Alerting - Anomaly Detection
>Solr & Elasticsearch Consulting Support Training - http://sematext.com/
>
>
>
>> On 5 Mar 2018, at 17:51, Christopher Schultz
><ch...@christopherschultz.net> wrote:
>>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA256
>>
>> All,
>>
>> I'd like for users to be able to search a field by multiple names
>> without performing a "copy-field" when analyzing a document. Is that
>> possible? Whenever I search for "solr alias field" I get results
>about
>> how to re-name fields in the results.
>>
>> Here's what I'd like to do. Let's say I have a document:
>>
>> {
>> id: 1234,
>> field_1: valueA,
>> field_2: valueB,
>> field_3: valueC
>> }
>>
>> I'd like users to be able to find this document using any of the
>> following queries:
>>
>> field_1:valueA
>> f1:valueA
>> 1:valueA
>>
>> I just want the query parser to say "oh, 'f1' is an alias for
>> 'field_1'" and substitute that when performing the search. Is that
>> possible?
>>
>> - -chris
>>
>> -----BEGIN PGP SIGNATURE-----
>> Comment: GPGTools - http://gpgtools.org
>> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>>
>> iQJRBAEBCAA7FiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlqddZMdHGNocmlzQGNo
>> cmlzdG9waGVyc2NodWx0ei5uZXQACgkQHPApP6U8pFgbFg/9HIgJgX4Lib2X4XYU
>> P2F4uW9TyDWtp6mA9xsfdYxRNe4K3yFPbkUUwJW2MI2V62SR6apB+TghOMqbmCD/
>> gaQ0CFWgLsn5Egulj2taUN+MAYD/4GMO9ltyXNc2g9siSMIDUS5N09fwJbxfBXrP
>> SPvSQqUOVD5wKCgoCXCVd+RM+SEClX4k1ZuWDbVAiO4YPpJwFy6+BN2uTCaqP3Ll
>> XOqn+/6ejnPCcvoQrTlE1/DiBTUti8H7V0LOjzEZns8YqZOAH+pAVxYRRQM5UzZS
>> pUBGpHokoaZ0tMf/aCmHp5pI5VWrxrXcS47csBRvoAn8Z7uRxH8p0wYE8BkGs2rw
>> dEzOSOKdhma11ZDkWKg2/sBw8v9swyWy9W3MuA0tqYzfZicsXT2GBHzyPDsqabDq
>> mBPWuxUdqZEaz+fE8SRsW84ELcqe1fbltscng/ZhNRkLOtmn6aeMc+XABhpcVE7o
>> Rfodl/PrQetgzZ4WLyzb7m2bz2w38x6WSPhuQIZHVrHNoCXG+gWY3zMxF6EBEFCV
>> CJvsXaQ1ZpGLjO/uCXJ9iHKxsSoUzWap9qws82xH3QJ52Q7vCoxF5G/2MZWvvgje
>> +MsZbh8L5D0HBM1jTKWx3X+r3FbdURu6P8yUFD/Hywy2J/jev1MiU4Zh3Yw+JByo
>> mR8TdvleHAHfA01tArVgk2yscqI=
>> =44DX
>> -----END PGP SIGNATURE-----
--
Sorry for being brief. Alternate email is rickleir at yahoo dot com
Re: Alias field names when searching (not for results)
Posted by Chris Hostetter <ho...@fucit.org>.
: > defType=edismax q=sysadmin name:Mike qf=title text last_name
: > first_name
:
: Aside: I'm curious about the use of "qf", here. Since I didn't want my
: users to have to specify any particular field to search, I created an
: "all" field and dumped everything into it. It seems like it would be
: better to change that so that I don't have an "all" field at all and
...
: Does that sound like a better approach than packing-together an "all"
: field during indexing?
well -- you may have other reasons why an "all" field is useful, but yeah
-- when using dismax/edismax the "qf" param is really designed to let you
search across many diff fields, and to associate query time weights with
those fields. see the docs i linked to earlier, but there's also a blog
post on the scoring implications i wrote a lifetime ago...
https://lucidworks.com/2010/05/23/whats-a-dismax/
: > ...the examples above all show the request params, so "f.last.qf"
: > is a param name, "last_name" is the corrisponding param value.
:
: Awesome. I didn't realize that "f.alias.qf" was the name of the actual
: parameter to send. I was staring at the Solr Dashboard's selection of
: edismax parameters and not seeing anything that seemed correct. That's
: because it's a new parameter! Makes sense, now.
that syntax is an example of a "per field override" where in this case the
"field" you are overriding doesn't *have* to be a "real" field in the
index -- it can be an alias and for that alias (when used by your users)
you are defining the qf to use. it could in fact be a "real" field name,
where you override what gets searched "I'm not going to let them search
directly against just the last_name, when they try i'm going to *actually*
search against last_name and full_name" etc...)
-Hoss
http://www.lucidworks.com/
Re: Alias field names when searching (not for results)
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Chris,
On 7/24/18 1:40 PM, Chris Hostetter wrote:
>
> : So if I want to alias the "first_name" field to "first" and the :
> "last_name" field to "last", then I would ... do what, exactly?
>
> se the last example here...
>
> https://lucene.apache.org/solr/guide/7_4/the-extended-dismax-query-par
ser.html#examples-of-edismax-queries
>
> defType=edismax q=sysadmin name:Mike qf=title text last_name
> first_name
Aside: I'm curious about the use of "qf", here. Since I didn't want my
users to have to specify any particular field to search, I created an
"all" field and dumped everything into it. It seems like it would be
better to change that so that I don't have an "all" field at all and
instead I mention all of the fields I would normally have packed into
the "all" field in the "qf" parameter. That would reduce my index size
and also help with another question I had today (subject: Possible to
define a field so that substring-search is always used?).
Does that sound like a better approach than packing-together an "all"
field during indexing?
> f.name.qf=last_name first_name
>
> the "f.name.qf" has created an "alias" so that when the "q"
> contains "name:Mike" it searches for "Mike" in both the last_name
> and first_name fields. if it were "f.name.qf=last_name
> first_name^2" then there would be a boost on matches in the
> first_name field.
>
> For your usecase you want something like...
>
> defType=edismax q=sysadmin first:Mike last:Smith qf=title text
> last_name first_name f.first.qf=first_name f.last.qf=last_name
>
> : I'm using SolrJ as the client.
>
> ...the examples above all show the request params, so "f.last.qf"
> is a param name, "last_name" is the corrisponding param value.
Awesome. I didn't realize that "f.alias.qf" was the name of the actual
parameter to send. I was staring at the Solr Dashboard's selection of
edismax parameters and not seeing anything that seemed correct. That's
because it's a new parameter! Makes sense, now.
Thanks a bunch,
- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAltXb9IACgkQHPApP6U8
pFifZxAAgQGXwsMzSQf9shJYmjgLgFWTYxQQBRJDFRgtEz0wtYkRS0nEoE+kO0xs
BEGC6iXfXChAkOQ3Bv/QittRCxCQvXL+aoZA5ewcyumf0XhmU0My4R7AJOoIRGpO
C9oPfUf8bwqynrTN0cXBIN8pr+KAG4rimAEMLxuscVeQAm3McrNbmmX22LL9VNRv
/QBDnil8rPCYiprQn7SnN88IkU9irgwN/1QQ+YaUhwOMubPwygfxGTdkTJivi0KA
fi5nmYE8A+wOzAGlP8GrMUZpkIfVx8VV96fwKdCyw+fi8MXVF+6rd+Z0u4TOI6Yq
ZQ3d/GK7W5OImWpQOJUX9oHRmoKiUgE/27XRb6QSC/WwF1WOonClmHggSKkh24a8
dGa+5A6tbPdCxJwv9T2NPn7XBqOyvNfxzMUnItpIdNoM0lrHCOMmANoU6nnSjrPg
iInAM9oG2p41zO8S83tv7KLVbOwS1xogmeUn5fr/5XQ5Z7g7V5yBE5oYgVTiUleB
Sd+wjoCWeZIfLSJJfRYFLLjQmFqQOh2Fc6XCoyBYQeGLrlCiNLRHIS6dEisHFNq8
PLbXNuMyZOkrvLNFUWwYhC9pwQ8Q8z3C0i1uVSYlOVDd1GHVwJowVI9XCFbAGFoO
0ZXSy3TuHMgk8VGUZNNO0H9nHf3i8MAoMo4TDsgROs2Y9TXRVPM=
=AEkI
-----END PGP SIGNATURE-----
Re: Alias field names when searching (not for results)
Posted by Chris Hostetter <ho...@fucit.org>.
: So if I want to alias the "first_name" field to "first" and the
: "last_name" field to "last", then I would ... do what, exactly?
se the last example here...
https://lucene.apache.org/solr/guide/7_4/the-extended-dismax-query-parser.html#examples-of-edismax-queries
defType=edismax
q=sysadmin name:Mike
qf=title text last_name first_name
f.name.qf=last_name first_name
the "f.name.qf" has created an "alias" so that when the "q" contains
"name:Mike" it searches for "Mike" in both the last_name and first_name
fields. if it were "f.name.qf=last_name first_name^2" then there would be
a boost on matches in the first_name field.
For your usecase you want something like...
defType=edismax
q=sysadmin first:Mike last:Smith
qf=title text last_name first_name
f.first.qf=first_name
f.last.qf=last_name
: I'm using SolrJ as the client.
...the examples above all show the request params, so "f.last.qf" is a
param name, "last_name" is the corrisponding param value.
-Hoss
http://www.lucidworks.com/
Re: Alias field names when searching (not for results)
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Emir,
On 3/6/18 2:42 AM, Emir Arnautović wrote:
> I did not try it, but the first thing that came to my mind is to
> use edismax’s ability to define field aliases, something like
> f.f1.fq=field_1. Note that it is not recommended to have field
> name starting with number so not sure if it will work with “1”.
So if I want to alias the "first_name" field to "first" and the
"last_name" field to "last", then I would ... do what, exactly?
I'm using SolrJ as the client.
queryParamMap.put("defType", "edismax");
queryParamMap.put([??], "f.first.fq=first_name f.last.fq=last_name");
??
Thanks,
- -chris
>> On 5 Mar 2018, at 17:51, Christopher Schultz
>> <ch...@christopherschultz.net> wrote:
>>
> All,
>
> I'd like for users to be able to search a field by multiple names
> without performing a "copy-field" when analyzing a document. Is
> that possible? Whenever I search for "solr alias field" I get
> results about how to re-name fields in the results.
>
> Here's what I'd like to do. Let's say I have a document:
>
> { id: 1234, field_1: valueA, field_2: valueB, field_3: valueC }
>
> I'd like users to be able to find this document using any of the
> following queries:
>
> field_1:valueA f1:valueA 1:valueA
>
> I just want the query parser to say "oh, 'f1' is an alias for
> 'field_1'" and substitute that when performing the search. Is that
> possible?
>
> -chris
>
>
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAltXUWwACgkQHPApP6U8
pFgytBAAnI5pSrmfo4vPr2Tvol+qeuBXXcJ1WogXI2CvE1wWfHUm0xOXXzJ+YzMb
glv9UFs+VBfzksM9p4anJ0zLSQ82DxMv+dQ4c/rgMxTMkA/Yj7/9yBxp2jniFz5k
Jaq6FlAcpmQYDKTTx8pZb9srIWfXRoQg2Kv4zFDftD9jQi5Fekn1wt4PuhIWdrWi
9ROX4Pajx6wyJccamfTr5xSiBnzDcA6CBGGMFPmXVPWozYqcDfz4Ohry5MgbHMaR
wz0NMHSFjQ6zF9ZI28RM1z7gMT5xB1mG5HgC5oQWVD2V0PULdAIWC7tDZhlFGE6p
USjELBdeV6NNARz3sIbI8MD+T0Ww0SIekJgz3xNcs8TMIi2k5s1ksEdJl5flrsZ5
wbR7hNYol2nb0Bx6p/wk9wXwxqfDrW9yT3gNg+kYRrEWZdfLqLOXrytTZ7BhTz1O
6xoUX58FugULPyj9zT/DFTxMicjzdLrXUZR9kpRZXZSDhhn9NrzC1zFYJVs/E7W5
2LzguS3zD6pR7stxAory4KaeuJEaU3pBo80P9jslOjBDrmZRIKFLCSaynTwxi2pF
Z0LXwGw/Vpc96sznBe4BYvWmxKkjYGCAUjrXM+tortr2SxH2dd2/umXySB5uQRV8
hAjBkidVLm1pB6jirzxLOzOMeIXb6zXnlLhBbvXBvYVpY9yQNuw=
=f0ub
-----END PGP SIGNATURE-----
Re: Alias field names when searching (not for results)
Posted by Emir Arnautović <em...@sematext.com>.
Hi,
I did not try it, but the first thing that came to my mind is to use edismax’s ability to define field aliases, something like f.f1.fq=field_1. Note that it is not recommended to have field name starting with number so not sure if it will work with “1”.
HTH,
Emir
--
Monitoring - Log Management - Alerting - Anomaly Detection
Solr & Elasticsearch Consulting Support Training - http://sematext.com/
> On 5 Mar 2018, at 17:51, Christopher Schultz <ch...@christopherschultz.net> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> All,
>
> I'd like for users to be able to search a field by multiple names
> without performing a "copy-field" when analyzing a document. Is that
> possible? Whenever I search for "solr alias field" I get results about
> how to re-name fields in the results.
>
> Here's what I'd like to do. Let's say I have a document:
>
> {
> id: 1234,
> field_1: valueA,
> field_2: valueB,
> field_3: valueC
> }
>
> I'd like users to be able to find this document using any of the
> following queries:
>
> field_1:valueA
> f1:valueA
> 1:valueA
>
> I just want the query parser to say "oh, 'f1' is an alias for
> 'field_1'" and substitute that when performing the search. Is that
> possible?
>
> - -chris
>
> -----BEGIN PGP SIGNATURE-----
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQJRBAEBCAA7FiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlqddZMdHGNocmlzQGNo
> cmlzdG9waGVyc2NodWx0ei5uZXQACgkQHPApP6U8pFgbFg/9HIgJgX4Lib2X4XYU
> P2F4uW9TyDWtp6mA9xsfdYxRNe4K3yFPbkUUwJW2MI2V62SR6apB+TghOMqbmCD/
> gaQ0CFWgLsn5Egulj2taUN+MAYD/4GMO9ltyXNc2g9siSMIDUS5N09fwJbxfBXrP
> SPvSQqUOVD5wKCgoCXCVd+RM+SEClX4k1ZuWDbVAiO4YPpJwFy6+BN2uTCaqP3Ll
> XOqn+/6ejnPCcvoQrTlE1/DiBTUti8H7V0LOjzEZns8YqZOAH+pAVxYRRQM5UzZS
> pUBGpHokoaZ0tMf/aCmHp5pI5VWrxrXcS47csBRvoAn8Z7uRxH8p0wYE8BkGs2rw
> dEzOSOKdhma11ZDkWKg2/sBw8v9swyWy9W3MuA0tqYzfZicsXT2GBHzyPDsqabDq
> mBPWuxUdqZEaz+fE8SRsW84ELcqe1fbltscng/ZhNRkLOtmn6aeMc+XABhpcVE7o
> Rfodl/PrQetgzZ4WLyzb7m2bz2w38x6WSPhuQIZHVrHNoCXG+gWY3zMxF6EBEFCV
> CJvsXaQ1ZpGLjO/uCXJ9iHKxsSoUzWap9qws82xH3QJ52Q7vCoxF5G/2MZWvvgje
> +MsZbh8L5D0HBM1jTKWx3X+r3FbdURu6P8yUFD/Hywy2J/jev1MiU4Zh3Yw+JByo
> mR8TdvleHAHfA01tArVgk2yscqI=
> =44DX
> -----END PGP SIGNATURE-----