Python 2.7 ha raggiunto la fine del supporto
e verrà
ritirato
il 31 gennaio 2026. Dopo il ritiro, non potrai eseguire il deployment di applicazioni Python 2.7, anche se la tua organizzazione ha utilizzato in precedenza un criterio dell'organizzazione per riattivare i deployment di runtime legacy. Le tue applicazioni Python 2.7 esistenti continueranno a essere eseguite e a ricevere traffico dopo la
data di ritiro. Ti consigliamo di
eseguire la migrazione all'ultima versione supportata di Python.
class ScoredDocument
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
La classe ScoredDocument
rappresenta un documento con punteggio restituito da una ricerca. Non devi creare questa classe esplicitamente; viene restituita come risultato di Index.search()
.
ScoredDocument
è definito nel modulo google.appengine.api.search
.
Costruttore
Il costruttore della classe MatchScorer
è definito come segue:
-
class ScoredDocument(doc_id=None, fields=None, language='it', sort_scores=None, expressions=None, cursor=None, rank=None)
Rappresenta un documento con punteggio restituito da una ricerca.
Argomenti
- doc_id
La stringa ASCII visibile e stampabile che identifica il documento. Non deve iniziare con "!". Gli spazi vuoti sono esclusi dagli ID. Se non viene fornito alcun ID, il servizio di ricerca ne fornirà uno.
- fields
Un iterable di istanze di Field che rappresentano i contenuti del documento.
- language
Il codice lingua ISO 639.2 di due lettere della lingua utilizzata nei valori di campo.
- sort_scores
L'elenco dei punteggi assegnati durante la valutazione dell'ordinamento. È inclusa ogni dimensione di ordinamento. I punteggi positivi vengono utilizzati per le selezioni in ordine crescente, mentre quelli negativi per quelle in ordine decrescente.
- espressioni
L'elenco dei campi calcolati che sono il risultato delle espressioni richieste.
- cursor
Un cursore associato al documento.
- rank
Il ranking del documento viene utilizzato per specificare l'ordine in cui il documento verrà restituito nei risultati di ricerca, dove 0 <= rank <= sys.maxint. Se non specificato, viene utilizzato il numero di secondi dal 1° gennaio 2011. I documenti vengono restituiti in ordine decrescente dell'ID ordine.
Valore del risultato
Una nuova istanza della classe ScoredDocument
.
Eccezioni
- TypeError
Se uno dei parametri ha un tipo non valido o viene passato un attributo sconosciuto.
- ValueError
Se un parametro ha un valore non valido.
Proprietà
Un'istanza della classe ScoredDocument
ha le seguenti proprietà:
- sort_scores
Restituisce l'elenco dei punteggi assegnati durante l'ordinamento dei risultati di una ricerca da parte dell'API. È inclusa ogni dimensione di ordinamento. I punteggi positivi vengono utilizzati per le selezioni in ordine crescente e quelli negativi per le selezioni in ordine decrescente.
- espressioni
L'elenco dei campi calcolati è il risultato della valutazione dell'espressione. Ad esempio, la seguente espressione di campo cerca di calcolare un campo snippet contenente snippet HTML estratti dalla corrispondenza della query 'good story'
nel campo content
:
FieldExpression(name='snippet', 'snippet("good story", content)')
In base a questa query, l'API restituirà il seguente ScoredDocument.expression
:
HtmlField(name='snippet', value='that was a good story to finish')
- cursor
Un cursore associato a un risultato utilizzato come punto di partenza da cui restituire l'insieme successivo di risultati di ricerca. Questa proprietà non viene restituita a meno che non imposti Index.cursor_type
su Index.RESULT_CURSOR
; in caso contrario, la proprietà restituita sarà None
.
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-09-04 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eScoredDocument\u003c/code\u003e class represents a scored document returned from a search operation and is not manually constructed but rather received as a result from \u003ccode\u003eIndex.search()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIt includes properties such as \u003ccode\u003edoc_id\u003c/code\u003e, \u003ccode\u003efields\u003c/code\u003e, \u003ccode\u003elanguage\u003c/code\u003e, \u003ccode\u003esort_scores\u003c/code\u003e, \u003ccode\u003eexpressions\u003c/code\u003e, \u003ccode\u003ecursor\u003c/code\u003e, and \u003ccode\u003erank\u003c/code\u003e which provide details about the document and its ranking.\u003c/p\u003e\n"],["\u003cp\u003eThe class allows the retrieval of scores generated during the sorting process (\u003ccode\u003esort_scores\u003c/code\u003e), computed fields from requested expressions (\u003ccode\u003eexpressions\u003c/code\u003e), and a cursor for paginated results (\u003ccode\u003ecursor\u003c/code\u003e) if configured.\u003c/p\u003e\n"],["\u003cp\u003eIf no \u003ccode\u003edoc_id\u003c/code\u003e is specified, one will be assigned by the search service.\u003c/p\u003e\n"],["\u003cp\u003eThe document's \u003ccode\u003erank\u003c/code\u003e property determines the order in which it appears in search results, with a higher \u003ccode\u003erank\u003c/code\u003e meaning the document is returned earlier in the results.\u003c/p\u003e\n"]]],[],null,["# class ScoredDocument\n\nClass `ScoredDocument` represents a scored document returned from a search. You do not build this class explicitly; rather, it is returned as a result of [Index.search()](/appengine/docs/legacy/standard/python/search/indexclass).\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n| python3\n|\n| /services/access). If you are updating to the App Engine Python 3 runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/python-differences) to learn about your migration options for legacy bundled services.\n\n`ScoredDocument` is defined in the `google.appengine.api.search` module.\n\nConstructor\n-----------\n\nThe constructor for class `MatchScorer` is defined as follows:\n\n\nclass ScoredDocument(doc_id=None, fields=None, language='en', sort_scores=None, expressions=None, cursor=None, rank=None)\n\n:\n\n Represents a scored document returned from a search.\n\n \u003cbr /\u003e\n\n:\n\n Arguments\n\n doc_id\n\n : The visible, printable ASCII string identifying the document. Must not begin with '!'. Whitespace is excluded from ids. If no id is provided, the search service will provide one.\n\n fields\n\n : An iterable of Field instances representing the content of the document.\n\n language\n\n : The two-letter [ISO 639.2 language code](http://www.loc.gov/standards/iso639-2/php/code_list.php) of the language used in the field values.\n\n sort_scores\n\n : The list of scores assigned during sort evaluation. Each sort dimension is included. Positive scores are used for ascending sorts; negative scores for descending.\n\n expressions\n\n : The list of computed fields which are the result of expressions requested.\n\n cursor\n\n : A cursor associated with the document.\n\n rank\n\n : The document rank is used to specify the order this document will be returned in search results, where 0 \\\u003c= rank \\\u003c= sys.maxint. If not specified, the number of seconds since 1st Jan 2011 is used. Documents are returned in descending order of the order ID.\n\n Result value\n\n : A new instance of class `ScoredDocument`.\n\n Exceptions\n\n TypeError\n\n : If any of the parameters have an invalid type, or an unknown attribute is passed.\n\n ValueError\n\n : If any parameter has an invalid value.\n\n \u003cbr /\u003e\n\nProperties\n----------\n\nAn instance of class `ScoredDocument` has the following properties:\n\nsort_scores\n\n: Returns the list of scores assigned while the API is sorting the results of a search. Each sort dimension is included. Positive scores are used for ascending sorts and negative scores for descending.\n\nexpressions\n\n: The list of computed fields the result of expression evaluation. For example, the following [field expression](/appengine/docs/legacy/standard/python/search/fieldexpressionclass) seeks to compute a snippet field containing HTML snippets extracted from the matching of the query `'good story'` in the `content` field:\n\n ```python\n FieldExpression(name='snippet', 'snippet(\"good story\", content)')\n ```\n Given this query, the API would return the following `ScoredDocument.expression`: \n\n ```python\n HtmlField(name='snippet', value='that was a good story to finish')\n ```\n\n \u003cbr /\u003e\n\ncursor\n\n: A cursor associated with a result used as a starting point from which to return the next set of search results. This property will not return unless you set the `Index.cursor_type` to `Index.RESULT_CURSOR`; otherwise the property returns be `None`."]]