Muhammad Haris Altaf
Muhammad Haris Altaf

Reputation: 567

Solr Field Alias in Solr Search is not working

The following link says we can use field aliases like id,price:crazy_price_field etc. I am trying to use it but this is not working. http://wiki.apache.org/solr/CommonQueryParameters#Field_alias https://issues.apache.org/jira/browse/SOLR-1205

My Query:

http://localhost:8080/solr/ee_core/select?indent=on&version=2.2&q=\*%3A\*&fq=%2BinstanceId_index_store%3A217&start=0&rows=10&fl=description_index_store%2Cscore&qt=&wt=json

fl=description_index_store,score gives correct result with field names description_index_store and score

{
    "responseHeader": {
        "status": 0,"QTime": 1,
        "params": {
            "explainOther": "","fl": "description_index_store,score",
            "indent": "on","start": "0","q": "*:*","hl.fl": "","qt": "",
            "wt": "json","fq": "+instanceId_index_store:217","rows": "3",
            "version": "2.2"
        }
    },
    "response": {
        "numFound": 128,"start": 0,"maxScore": 1,
        "docs": [
            {
                "description_index_store": "Apple MacBook - Intel Core 2 Duo",
                "score": 1
            },
            {
                "description_index_store": "Apple MacBook - Intel Core 2 Duo",
                "score": 1
            },
            {
                "description_index_store": "HP Envy - 17.3\" - Intel Core i7",
                "score": 1
            }
        ]
    }
}

but when i try to use alias like fl=description:description_index_store,score in the same query it doesn't return the field.

{
    "responseHeader": {
        "status": 0,"QTime": 0,
        "params": {
            "explainOther": "","fl": "description:description_index_store,score",
            "indent": "on","start": "0","q": "*:*","hl.fl": "","qt": "",
            "wt": "json","fq": "+instanceId_index_store:217","rows": "3",
            "version": "2.2"
        }
    },
    "response": {
        "numFound": 128,"start": 0,"maxScore": 1,
        "docs": [
            {
                "score": 1
            },
            {
                "score": 1
            },
            {
                "score": 1
            }
        ]
    }
}

Upvotes: 2

Views: 6453

Answers (1)

javanna
javanna

Reputation: 60205

You're referring to a feature which has been added to the 4.0 version of Solr, not yet released. In fact, within the fl section of that wiki page there's an exclamation mark which tells you that the following content (still within the fl section) is available only with Solr 4.0.

The SOLR-1205 issue has been addressed, together with other improvements, within SOLR-2444: Update fl syntax to support: pseudo fields, AS, transformers, and wildcards, which will be released with Solr 4.0. You might want to have a look at the Solr 4.0 roadmap to find out when it should be released.

Upvotes: 3

Related Questions